Hi Rafael,

In gRPC server streaming, client doesn't need to close the connection. When 
client sends the server request, client half closes the connection and 
listen to server response. 

According to the example code, looks like you are making blocking server 
streaming call from client.

In that case, when you perform the call and you get response, server 
already sent all responses to client and both client and server close the 
connection. We can read server responses from iterator.

Please correct me if I am wrong.

Thanks
Danesh

On Thursday, January 31, 2019 at 6:21:27 PM UTC+5:30, [email protected] 
wrote:
>
>
> Hi all,
>
> I am facing some problems trying to close a Server-Stream call from the 
> client side.
>
> The client opens the channel, create the stub, etc and try to perform the 
> call which returns an Iterator<Item>.
>
> The grpc java examples show how to read the data from this Iterator is 
> using for example a while loop, but not how the client could close it (onle 
> the server can do so)
>
> <code>
>
> Iterator<Item> response = stub.getData()
>
> while(response.hasNext())
> {
>       response.next();
> }
>
> </code>
>
> In case I want to close this call, what is the best way to do it? or at 
> least something that makes it works?
>
> I have tried out something like this, whenever it goes out of the while 
> loop it will "destroy, cancel" the iterator, but it does not work:
>
> <code>
>
> Iterator<Item> response = stub.getData()
>
> while(response.hasNext() && !condition)
> {
>       response.next();
> }
> response = null;
>
> </code>
>
> Kind regards,
> Rafael.
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/48e0d7f6-7be5-4291-bf96-61cb5a39808b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to