Replies: 1 comment 1 reply
-
I'm interested in using proxies with Tonic but I'm a Rust newbie and it feels like I'll end up working on it for 3 days before ending up finding weird bugs (like compression not working – thanks for mentioning it, since it's rather critical to my use case...) Perhaps the simplest way to go about this would be to fork tonic and add the functionality there? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So far
Tonic
do not support proxy, so I have to write a custom HTTP client and use withEchoClient::with_origin(client, uri)
(takeEchoClient
as an example which's generated with tonic-build).At first, I simply use
hyper::Client
with my customizedConnector
with proxy support. However, when compression is enabled,Tonic
will not work with error:protocol error: received message with compressed-flag but no grpc-encoding was specified
. I've checked docs and found nothing related with such error and I have to read source codes.Func call tracking:
tonic/tonic/src/client/grpc.rs
Lines 280 to 367 in e31f5cc
stream
->->create_response
-> expect_additional_trailers = false ->Streaming::new_empty(decoder, body)
->Streaming::new(decoder, body, Direction::EmptyResponse, None, None)
Here encoding is
None
though actuallyGzip
, then error occurs.In func
stream
, inner Tcall
the request and gets response from upstream. By comparing the response headers between offcial example and my own one, I noticed thatgrpc-status
,grpc-status-message
andgrpc-status-details-bin
were removed when in offcial example. I guessed that tonicChannel
will handle gRPC Status before decoding response and removegrpc-status
,grpc-status-message
andgrpc-status-details-bin
from response headers, while hyper::Client will not do so.Finally, I write a wrapper of hyper::Client and impl
tower::Service
for it, then check tonic::Status and removegrpc-status
,grpc-status-message
andgrpc-status-details-bin
from response headers. It works!I'm not sure if I'm right and I would be really happy if anyone could share more details in the comment area.
P.S. Any convenient ways on tracing function calls in Rust?
Beta Was this translation helpful? Give feedback.
All reactions