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.

Content-length: 0 confuses grpc-web client

See original GitHub issue

A gRPC server could send back a gRPC response without any body, for example, a gRPC error response. However, some server could choose not to use “trailers-only” to send back the “grpc-status”. Instead, it still uses “headers”, “empty body”, “trailers” HTTP/2 frames, and the grpc-status and grpc-message are set in the trailers.

There could be scenario when “content-length: 0” is added to the response header as the body is empty. For example, if the gRPC server is fronted by an envoy, the envoy could add “C-L: 0”. See https://github.com/envoyproxy/envoy/issues/5554. An example response looks like this:

envoy_1   | [2021-06-19 02:40:08.061][15][debug][http] [source/common/http/conn_manager_impl.cc:1472] [C6][S17521888214259471014] encoding headers via codec (end_stream=false):
envoy_1   | ':status', '200'
envoy_1   | 'grpc-accept-encoding', 'identity'
envoy_1   | 'grpc-encoding', 'identity'
envoy_1   | 'content-type', 'application/grpc+proto'
envoy_1   | 'date', 'Sat, 19 Jun 2021 02:40:08 GMT'
envoy_1   | 'server', 'envoy'
envoy_1   | 'x-cloud-trace-context', 'a86f4f6eeee8e5baccd463176c163b05/11003727237429165764'
envoy_1   | 'content-length', '0'
envoy_1   | 'x-envoy-upstream-service-time', '170'
envoy_1   |
envoy_1   | [2021-06-19 02:40:08.062][15][debug][client] [source/common/http/codec_client.cc:130] [C7] response complete
envoy_1   | [2021-06-19 02:40:08.062][15][debug][pool] [source/common/conn_pool/conn_pool_base.cc:200] [C7] destroying stream: 0 remaining
envoy_1   | [2021-06-19 02:40:08.062][15][debug][http] [source/common/http/conn_manager_impl.cc:1488] [C6][S17521888214259471014] encoding trailers via codec:
envoy_1   | 'grpc-status', '200'
envoy_1   | 'grpc-message', 'invalid%20input'

For this case, as grpc-web filter doesn’t strip content-length nor update content length after it encodes the trailers and puts it into the response body. The output from the filter could confuses the grpc-web client and makes it reject the response.

See a reproduction case in https://github.com/ridedott/grpc-web-cloud-run-issue And confirm removing content-length header makes the grpc-web client happy: https://github.com/ridedott/grpc-web-cloud-run-issue

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

2reactions
efossvoldcommented, Nov 16, 2021

#1050 (comment) solved it for us.

1reaction
LukeLaScalacommented, Sep 20, 2021

Hey all. What’s the current status on this and are there any workarounds in the time being?

Read more comments on GitHub >

github_iconTop Results From Across the Web

grpc/grpc - Gitter
Hi, I have question related to gRPC-java. We are seeing server calls not being closed after calling StreamObserver.onCompleted() , the stream just hangs...
Read more >
GRPC Web Request using golang client? - Stack Overflow
The idea is to use this grpc server both with browser based application as well as with the normal grpc client. But i...
Read more >
Envoy can't connect to local upstream server - Google Groups
Local REACT gRPC client -> Envoy running inside Docker, listening on Port ... -encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout.
Read more >
Search Results - CVE
CVE-2022-45347, Apache ShardingSphere-Proxy prior to 5.3.0 when using MySQL as database backend didn't cleanup the database session completely after client ...
Read more >
CHANGELOG.md - Kong/kong - Sourcegraph
which have less specificity #8233; The internal DNS client isn't confused by ... kong.response.exit now uses customized "Content-Length" header when found ...
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