You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So far Tonic do not support proxy, so I have to write a custom HTTP client and use with EchoClient::with_origin(client, uri) (take EchoClient as an example which's generated with tonic-build).
At first, I simply use hyper::Client with my customized Connector 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.
Here encoding is None though actually Gzip, then error occurs.
In func stream, inner T call the request and gets response from upstream. By comparing the response headers between offcial example and my own one, I noticed that grpc-status, grpc-status-message and grpc-status-details-bin were removed when in offcial example. I guessed that tonic Channel will handle gRPC Status before decoding response and remove grpc-status, grpc-status-message and grpc-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 remove grpc-status, grpc-status-message and grpc-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?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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