-
Notifications
You must be signed in to change notification settings - Fork 435
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
Server stream does not detect client's disconnection #57
Comments
Thanks for raising. Can you provide a repro please? |
Hi, I have the same problem. In the stream example a servers pushes and ends the stream. But in this context (which i also have) the server has many clients and sends endless. Clients come and go.
It should give an error even when a client abruptly gets killed with no clean Close() Thanks for fixing.. |
Starting from the example server, replace the method in func (s *bookService) QueryBooks(bookQuery *library.QueryBooksRequest, stream library.BookService_QueryBooksServer) error {
for {
grpclog.Info("sending to", stream)
err := stream.Send(books[0])
if err != nil {
grpclog.Error("got error", err, "from", stream)
break
}
time.Sleep(time.Second)
}
grpclog.Info("done with", stream)
return nil
} The idea is to send a message every second. The output from the server looks like:
Thank you |
Workaround is to check the stream context: err = stream.Context().Err()
if err != nil {
break
} |
Closing due to inactivity. Please comment if you'd like to revisit this issue. |
The workaround provided by @jsmouret does indeed work, but shouldn't @easyCZ thoughts? |
Anything like http CloseNotify? |
I have the exact same issue but I would like to handle it in the proxy server, in which I don't have access to the stream handler so I can't put this work around. |
In my application, the client requests data that is returned through a stream. But if the client crashes, the server keeps writing into the stream without any error.
The text was updated successfully, but these errors were encountered: