Awesome, thanks! That was what I was looking for.
On Monday, October 31, 2016 at 9:33:39 AM UTC-7, Eric Anderson wrote:
>
> Blocking stub observers thread interruption; if the thread is interrupted
> it will cancel the RPC.
>
> For async stub, you can create a CancellableContext and cancel it:
>
> CancellableContext withCancellation = Context.current().withCancellation();
> withCancellation.run(new Runnable() {
> @Override public void run() {
> stub.listFeatures(rectangle, observer);
> }
> });
>
> When the RPC completes, make sure to call withCancellation.cancel(null);,
> otherwise you can start retaining memory.
>
> When you want to cancel the RPC call withCancellation.cancel(someEx);.
> The exception is just used for your own debugging, since without it it
> would be hard to tell where cancellations come from.
>
> On Wed, Oct 19, 2016 at 5:08 PM, Edmund <[email protected] <javascript:>>
> wrote:
>
>> Hello!
>>
>> I am trying to close a server-side streaming stream by the client but
>> cannot seem to find a way to do it without closing the whole connection or
>> channel. The proto file has a service like this:
>>
>> rpc ListFeatures(Rectangle) returns (stream Feature) {}
>>
>> When I use stub.ListFeatures() it does not return a StreamObserver like
>> a bi-directional stream. So I cannot call onComplete() and have the
>> stream close without closing the channel.
>>
>> Any thoughts?
>>
>> * I also tried using a blockingStub, loop and flag. However, it would get
>> stuck in hasNext()when waiting for messages and I cannot break out with
>> a flag
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> 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/31ef938c-f3c1-4a88-a73c-f6f0ae15e1c2%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/grpc-io/31ef938c-f3c1-4a88-a73c-f6f0ae15e1c2%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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/81a439ef-f4cf-4e0a-a491-838a4ba60e9e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.