-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need a way to stop server side streaming when client disconnected #6456
Comments
Couple of ways:
|
Thank you for your reply. In my logic, the server returns an infinite event stream that a healthy client consumes event from, so A workaround is change someMethod to bi-stream, and treat client stream as Ping, but it looks not good... |
If the client has crashed and your |
What do you mean by "crashes"? If the client process closes the socket after it "crashes", the stream will be closed and server RPC context will be cancelled. What you are currently checking in your |
Thank you. most of heavyCompute() call returns null, no matter if client gone, I just want to quit as soon as possible to save resources. |
"crashes" means that client has no chance doing any clean operation, e.g.: network connections broken, or a segmentation exception. Here is a simple logic with pseudo code: I've waited for someMethod at server-side for 100 seconds, but it didn't terminated as Context.current().isCancelled() returned false. |
If client or network failed so badly that it has not chance notifying the server side, the TCP connection could stall for very long time until it times out. You can try setting
I thought you were complaining the case when client crashes, not when the client calls |
Thank you for your reply, but I found NettyServerBuilder was introduced at 2016, until now, it has being an experimental feature. Do we plan to turn it normal?
|
NettyServerBuilder is pretty stable, but it depends on Netty's feature, we reserve the right to change its interface if necessary (e.g., some breaking changes in Netty). In general, we will avoid such a change as much as possible. |
@pengfeiwang-cn If you are developing libraries that other people are depending on, do not use ExperimentalAPI; if you are developing applications, the keepalive API in NettyServerBuilder is pretty safe to use in production. |
here is pseudo code to impl a server side streaming:
On client side, if everything is ok, CancellableContext.cancel() or ManagedChannel.shutdownNow() will terminate someMethod call gracefully, but if client crashes && heavyCompute always returns null, someMethod call will run forever...
so is there a way to fix this?
Thanks.
The text was updated successfully, but these errors were encountered: