Add example of detecting client drops in bidirectional streams on server side#931
Conversation
LucioFranco
left a comment
There was a problem hiding this comment.
Looks like a good start! Left a few comments.
| } | ||
| } | ||
|
|
||
| async fn bidirectional_streaming_echo_throttle(client: &mut EchoClient<Channel>, dur: Duration) { |
There was a problem hiding this comment.
Not following why we want this example as well?
There was a problem hiding this comment.
I wanted to show difference between graceful stream end the one when client disconnected for example by broken connection or just crush. This 2 functions could be unified to one.
Here is the output from server part.
EchoServer::server_streaming_echo
client connected from: Some([::1]:36750)
client disconnected
EchoServer::Bidirectional_streaming_echo
stream ended
EchoServer::Bidirectional_streaming_echo
client disconnected: broken pipe
stream ended
There was a problem hiding this comment.
In other words the difference is on the server side. On the client side I just needed a function that sends request slowly enough that you can write what is printed. I added additional comments to clarify that.
Should I unify this to bidirectional_streaming_echo(client &mut EchoClient<Channel>, num_reqs: usize, throttle: Duration)?
closes #781
I think that this example shows also a weakness of tonic. For example in
async fn server_streaming_echo()function is impossible (or I do not know how) to get reason whyoutput_streamwasn't able to send message to client.Motivation
Provide example how to detect client disconnection on server side
Solution
Use
tokio::spawnto separate await on input stream from output stream.