server-side timeout?

25 views
Skip to first unread message

Vijay Lakshminarayanan

unread,
Nov 1, 2018, 11:09:14 AM11/1/18
to grp...@googlegroups.com
Hi

I'd like to cap the longevity of any client request on the server's
side. Is this possible?

Thanks
Vijay

robert engels

unread,
Nov 1, 2018, 11:20:20 AM11/1/18
to Vijay Lakshminarayanan, grp...@googlegroups.com
In Go, you can set the Context with Deadline, and the server side handler can check if the request should be aborted (which may happen automatically if the Context is passed to another service, like db connection).
> --
> 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 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CALRoXF0syS4nR7X9kyqCPkrPajDb%2B1rpL09jukUQkPkPvBR_PA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Vijay Lakshminarayanan

unread,
Nov 1, 2018, 11:23:04 AM11/1/18
to ren...@earthlink.net, grp...@googlegroups.com
Thanks Robert. I forgot to mention that I'm using Java. I'll look
for the equivalent APIs in Java.

Thanks
Vijay

robert engels

unread,
Nov 1, 2018, 11:26:02 AM11/1/18
to Vijay Lakshminarayanan, grp...@googlegroups.com
Here:

response = blockingStub.withDeadlineAfter(deadlineMs, TimeUnit.MILLISECONDS).sayHello(request);

from

robert engels

unread,
Nov 1, 2018, 11:27:20 AM11/1/18
to Vijay Lakshminarayanan, grp...@googlegroups.com
And the server side checking:

Java

if (Context.current().isCancelled()) {
  responseObserver.onError(Status.CANCELLED.withDescription("Cancelled by client").asRuntimeException());
  return;
}


Reply all
Reply to author
Forward
0 new messages