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
Uh oh!
There was an error while loading. Please reload this page.
-
So far
Tonicdo not support proxy, so I have to write a custom HTTP client and use withEchoClient::with_origin(client, uri)(takeEchoClientas an example which's generated with tonic-build).At first, I simply use
hyper::Clientwith my customizedConnectorwith proxy support. However, when compression is enabled,Tonicwill 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
Nonethough actuallyGzip, then error occurs.In func
stream, inner Tcallthe request and gets response from upstream. By comparing the response headers between offcial example and my own one, I noticed thatgrpc-status,grpc-status-messageandgrpc-status-details-binwere removed when in offcial example. I guessed that tonicChannelwill handle gRPC Status before decoding response and removegrpc-status,grpc-status-messageandgrpc-status-details-binfrom response headers, while hyper::Client will not do so.Finally, I write a wrapper of hyper::Client and impl
tower::Servicefor it, then check tonic::Status and removegrpc-status,grpc-status-messageandgrpc-status-details-binfrom 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