Sorry for the delayed response. You should take a look at 
it is a good example of client code that has a dedicated thread to drive 
work forward on RPCs. In the main body of the file, we start a thread that 
loops over AsyncCompleteRpc 
which will block on AsyncNext, and proceed whenever there are bytes to be 
read from the wire.

For a more complex example of this type of pattern, take a look at our QPS 
Driver <> codebase 
(especially client.h and That has a similar pattern, but 
allows threading to be controlled more finely (and supports all types of 

On Monday, April 2, 2018 at 2:22:36 PM UTC-7, wrote:
> Hi everyone,
> I'm trying to integrate gRPC in my application and I'm having some issues. 
> This is mostly the workflow I have in my app:
> 1. a thread that does a bunch of different things
> 2. every second reads gRPC response of the request sent last second
> 3. at the same time it sends a new gRPC request to another process
> It's very important for us that every second we read the response 
> calculated by the other process. What I did so far is:
> 1. use AsyncNext with timeout 0 on CompletionQueue to read any data 
> available
> 2. Compose a new request and send it via Stub::AsyncSayHello and Finish()
> (just using this an example 
> my code is equivalent)
> But it does not quite work, basically the server responds immediately but 
> the first call to AsyncNext just gives a timeout, calling again AsyncNext 
> instead gives the response.
> My questions is: Isn't there any API that allows to *read anything you can 
> from the socket*?
> I can also just call AsyncNext multiple times until it's done but how can 
> I know that there is yet something else to parse if I just receive TIMEOUT?
> My understanding is that I just need to call AsyncNext to keep things 
> going, how do you suggest to implement this? Like having a different thread 
> just doing AsyncNext for all my gRPC calls?
> Anybody that can explain this behaviour better to me would be very 
> appreciated, I'll be happy to send PR to update documentation if afterwards 
> if needed.
> Thanks,
> Luca

You received this message because you are subscribed to the Google Groups 
"" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

Reply via email to