Skip to content
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

how to set stream.Recv() timeout? #445

Closed
xtaci opened this issue Nov 16, 2015 · 12 comments
Closed

how to set stream.Recv() timeout? #445

xtaci opened this issue Nov 16, 2015 · 12 comments

Comments

@xtaci
Copy link

xtaci commented Nov 16, 2015

how to set stream.Recv() timeout?

@iamqizhao
Copy link
Contributor

You can wait on another goroutine and cancel the stream if the timer fires.

@shafreeck
Copy link

I don't think its a good way to rely on a separate goroutine. Why not build the timeout feature in like using context ?

@iamqizhao
Copy link
Contributor

To be clear, the scope of context is rpc (either unary or streaming) instead of a particular message.

@Julio-Guerra
Copy link

Julio-Guerra commented Dec 2, 2017

I'm wondering if this is that clear on the documentation. It really deserves a "Client-Server Synchronization" and "Handling errors" chapters.

@xtaci
Copy link
Author

xtaci commented Dec 2, 2017

absolutly, doc is not clear enough

@jan4984
Copy link

jan4984 commented Dec 28, 2017

@iamqizhao how to cancel a strem.recv() for bidi-streaming rpc at server side. I not find any stream mehtod.

@MakMukhi
Copy link
Contributor

@jan4984 You can cancel a stream by canceling the context used to create it.

@jan4984
Copy link

jan4984 commented Dec 28, 2017

@MakMukhi no, I mean the server side. The stream is allocated by gRPC framewok.

@nhooyr
Copy link

nhooyr commented Dec 28, 2017

@jan4984 You would return from the goroutine that received the stream.

@jan4984
Copy link

jan4984 commented Dec 29, 2017

@nhooyr but how can I return if I'm blocking at recv() call

@nhooyr
Copy link

nhooyr commented Dec 29, 2017

@jan4984 recv in a different goroutine.

@dfawley
Copy link
Member

dfawley commented Jan 2, 2018

See also #1229 (esp. this comment and below), which is about Send() deadlines but the same concepts/techniques apply.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants