grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.64k stars 764 forks source link

Does gRPC-Web Javascript client application supports gzip compression from gRPC .Net service? #1000

Open MahalingamVenkat opened 3 years ago

MahalingamVenkat commented 3 years ago

I have a .Net gRPC service that returns gzip compressed response with "grpc-encoding" response header set to gzip. However, the protoc generated js files were not able to decode the response and failing with the error "net::ERR_CONTENT_DECODING_FAILED". The client was able to read the response from the service correctly when gzip compression is not done at the service. Setting the "content-encoding" response header also does not solve the issue.

I understand that the browser is supposed to handle this decoding but it is not happening for gRPC response calls. Can you please let know whether gRPC-web with Javascript client works with gzip response data from server?

stanley-cheung commented 3 years ago

Probably same issue as #561

MahalingamVenkat commented 3 years ago

Probably same issue as #561 Thanks for your response. Not sure whether the issue is the same. The tech stack here is different (.Net core 3.1 gRPC service) and it fails at the client side while reading the response. When the response from this gRPC service is “GZip” compressed, the browser is not able to decompress the data. The gRPC-Web calls are failing with the below error: Error seen in browser console: net::ERR_CONTENT_DECODING_FAILED 200 (Tried in both new Edge and Chrome)

Request-headers (specific to this issue): accept-encoding: gzip, deflate, br grpc-accept-encoding : gzip content-type: application/grpc-web+proto (Tried with application/grpc-web-text also)

Response-headers (specific to this issue): content-type: application/grpc-web content-encoding: gzip grpc-encoding: gzip

Does auto-generated JS files need any further changes to read the gzip compressed response from the service? I know the decoding should be handled by the browser but it is not happening in this case. Would like to understand whether it is a general issue with gzip response across other tech stack.

anupkrish24 commented 3 years ago

@MahalingamVenkat did you end up figuring this out? We want to compress our responses from a gRPC service using gzip as well - wondering if we need to do anything special here to handle this.

anupkrish24 commented 3 years ago

A little confused since the doc mentions compression for unary responses is supported (https://github.com/grpc/grpc-web/blob/master/doc/browser-features.md#compression):

Full-body compression is supported and expected for all unary requests/responses. The compression/decompression will be done by browsers, using standard Content-Encoding headers