Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRPC server seems to always compress messages even if client does not support it. #669

Open
RubenGarcia opened this issue Sep 18, 2023 · 5 comments
Labels

Comments

@RubenGarcia
Copy link
Contributor

GRPC server seems to always compress messages even if client does not support it. See https://github.com/Cysharp/YetAnotherHttpHandler/issues/19 where client is complaining with the line Request sent 'identity' grpc-encoding value with compressed message. #19

<version of the grpc-dart packages used; see your pubspec.lock file>
grpc:
dependency: "direct main"
description:
name: grpc
sha256: "220ffb2218288f4e7dea487242e08b9c6277596d9b6f3f10ba50be96771a032d"
url: "https://pub.dev"
source: hosted
version: "3.2.3"

Repro steps

  1. Generate a dart grpc server
  2. Use Unity and YetAnotherHttpHandler to connect to it

Expected result:
The client receives the correct answer

Actual result:
Request sent 'identity' grpc-encoding value with compressed message. #19

@RubenGarcia
Copy link
Contributor Author

Removing compression using

 codecRegistry: CodecRegistry(codecs: const [/*GzipCodec(), */IdentityCodec()]),

does not make a difference.

@RubenGarcia
Copy link
Contributor Author

Version: "3.2.4" is also affected.

@RubenGarcia
Copy link
Contributor Author

Tested on android and on osx, both platforms have the issue.

@RubenGarcia
Copy link
Contributor Author

RubenGarcia commented Mar 19, 2024

After some debugging, these are my results:

  • https://grpc.github.io/grpc/core/md_doc_compression.html

    • An ill-constructed message with its Compressed-Flag bit set but lacking a grpc-encoding entry different from identity in its metadata MUST fail with INTERNAL status
  • grpc-3.2.4\lib\src\shared\message.dart

    • List frame(List rawPayload, [Codec? codec]) {}
      • when called with codec == IdentityCodec
        • header.setUint8(0, codec == null ? 0 : 1);
          • ^-- this is returning 1 (i.e. the compressed flag is set)
          • message-encoding is set to identity

This means the grpc message is ill-constructed. The correct condition should be

header.setUint8(0, (codec == null || codec.encodingName =="identity") ? 0 : 1);

RubenGarcia pushed a commit to RubenGarcia/grpc-dart that referenced this issue Mar 19, 2024
RubenGarcia added a commit to RubenGarcia/grpc-dart that referenced this issue Mar 19, 2024
@RubenGarcia
Copy link
Contributor Author

Merge request fixing the issue.
#693

@mosuem mosuem mentioned this issue Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants