-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
gRPC bi-directional streaming: Close stream from client. #3230
Comments
Well, I found out the solution... But I am confused. Why we need to create a new context from the old context to cancel the stream? |
Which And |
Thanks for the reply! I double checked my code and now the And I tested that both Today I have another question... I have created a context Can I use a shared context in a sequence of requests? Currently I am doing so and it works fine. But after reading some posts about context, it makes me feel that using a shared context is a bad idea. But I can't see any potential problem. Thanks! |
In general I would say: don't. It might work now, but that's mostly because you never do anything to those contexts. If you share the context between two RPCs, you won't be able to cancel only one, because canceling the context will cancel both. |
Got it! Thank you. |
I have a bi-directional streaming RPC. On the client side, I have a goroutine like this
Now I want to close the stream, which receive data from server. But, when I invoke context
cancel()
andClientConn.Close()
, thestream.Recv
is still blocking there.Any suggestion on how to close the server stream on client side?
The text was updated successfully, but these errors were encountered: