Grpc-java - simulating disconnect from a streaming response api

68 views
Skip to first unread message

aru...@gmail.com

unread,
Feb 1, 2018, 3:49:24 AM2/1/18
to grpc.io
Hi,

We want to force the grpc client to disconnect from a streaming response API in a test case. I could not figure out how to do that.

Andreas Pillath

unread,
Feb 1, 2018, 7:55:48 AM2/1/18
to grpc.io
Maybe you could do something like this:

CancellableContext context = Context.current().withCancellation();
context.run(() -> stub.doStream(StreamRequest.getDefaultInstance(), new TestStreamObserver()));
...
context.cancel(io.grpc.Status.ABORTED.asException());

Kun Zhang

unread,
Feb 1, 2018, 8:29:46 PM2/1/18
to grpc.io
Is it client-side application or server-side service implementation you are testing?
Are you trying to simulate stream closure or connection closure?
Are you using the in-process transport?

Arun Jain

unread,
Feb 2, 2018, 2:21:51 AM2/2/18
to Kun Zhang, grpc.io
Hi,

I am testing client side application. I am trying to close the stream and not the whole connection. No, client and server are two different process communicating over network.

--
You received this message because you are subscribed to a topic in the Google Groups "grpc.io" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grpc-io/bbxe2-YmkUI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
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/9cbb4005-6500-44e9-9558-a89252deface%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Carl Mastrangelo

unread,
Feb 5, 2018, 6:14:18 PM2/5/18
to grpc.io
You can call onCompleted on the stub to end the stream.    Is there something more you wanted to do?


On Thursday, February 1, 2018 at 11:21:51 PM UTC-8, Arun Jain wrote:
Hi,

I am testing client side application. I am trying to close the stream and not the whole connection. No, client and server are two different process communicating over network.
On Fri, Feb 2, 2018 at 6:59 AM, 'Kun Zhang' via grpc.io <grp...@googlegroups.com> wrote:
Is it client-side application or server-side service implementation you are testing?
Are you trying to simulate stream closure or connection closure?
Are you using the in-process transport?

On Thursday, February 1, 2018 at 12:49:24 AM UTC-8, aru...@gmail.com wrote:
Hi,

We want to force the grpc client to disconnect from a streaming response API in a test case. I could not figure out how to do that.

--
You received this message because you are subscribed to a topic in the Google Groups "grpc.io" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grpc-io/bbxe2-YmkUI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
Reply all
Reply to author
Forward
0 new messages