question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Response parsing breaks with 'grpc-encoding: gzip'

See original GitHub issue

When the gRPC response is gzipped (indicated by the grpc-encoding: gzip response header), the grpc-web stream parser fails with this error (including the first few bytes for reference):

Uncaught Error: The stream is broken @0/0. Error: invalid frame byte. With input:
1,0,0,2,126,31,...

And the grpc-web filter in Envoy unfortunately automatically adds this request header when proxying to the gRPC server: grpc-accept-encoding:identity,deflate,gzip, which in the case of akka-grpc at least causes the server to gzip. The envoy source code has a comment stating that this header ‘is required for gRPC’.

When I hacked akka-grpc to ignore the above header and not gzip, the response is properly parsed.

I’m a backend engr., but if someone can give me some pointers I could take a stab at fixing this.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:14

github_iconTop GitHub Comments

4reactions
MahalingamVenkatcommented, Dec 27, 2020

@stanley-cheung We are also facing similar issue with gzip compression not supported by grpc-web. Issue #1000 The protobuf payload is larger than the gzipped JSON payload and this adds to the increased response time. We are not able to move to grpc-web currently for our JS client to service calls due to this issue.

Any plans you could share on this gzip support being added in the near future? Or any other suggestions in terms of other compression that grpc-web supports or ways to mitigate the issue?

1reaction
otto-devcommented, Oct 2, 2019

This cost me some hours. Here is a solution, a bit of code to get others started that run into this issue with Akka HTTP:

    val service = NetworkWorkersHandler(new NetworkWorkersService())
    val handler: HttpRequest => Future[HttpResponse] = { request =>
      val withoutEncoding = request.copy(headers = request.headers.filterNot(_.name == "grpc-accept-encoding"))
      service(withoutEncoding)
    }
    val binding = Http().bindAndHandleAsync(
      handler,
      interface = "127.0.0.1",
      port = 8000,
      connectionContext = HttpConnectionContext(),
    )
Read more comments on GitHub >

github_iconTop Results From Across the Web

Gzip compression in response from gRPC-java to gRPC-web
But when I send compressed response my client fall with error 'Error in parsing response body'. And my response payload don't decompress with...
Read more >
rpc_util.go - Google Git
"google.golang.org/grpc/encoding/proto" ... NewGZIPCompressor creates a Compressor based on GZIP. ... func recv(p *parser, c baseCodec, s *transport.
Read more >
Chapter 4, gRPC: Under the Hood - O'Reilly
The service stub parses the message bytes into language-specific data structures ... The response message follows the same procedure that we observed on...
Read more >
asp.net - GZip compression broken after three hard reloads
Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress); context.Response.AppendHeader("Content-encoding", "gzip"); ...
Read more >
Troubleshooting the GitLab agent for Kubernetes
... net/http: HTTP/1.x transport connection broken: malformed HTTP response ... Decompressor is not installed for grpc-encoding.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found