Deadline with FutureStub

32 views
Skip to first unread message

Baojun Xu

unread,
Mar 19, 2018, 5:50:43 AM3/19/18
to grp...@googlegroups.com, Jun Li
Hi,

I am trying to use withDeadlineAfter() on a futureStub, but noticed that an error DEADLINE_EXCEEDED" is always thrown when a rpc is made on the futureStub for a second time.

Just wondering why this is the case? Maybe there is some restrictions to use deadlines with FutureStubs?

Any help is appreciated!

Best,
Baojun

spenc...@google.com

unread,
Mar 19, 2018, 11:58:17 AM3/19/18
to grpc.io
I think it's because calling `withDeadlineAfter` applies the timestamp of the deadline to a new stub and returns that new stub to you. If the deadline value is small, the deadline may expire before you have a chance to finish your second RPC. This is true for all stubs. Creating new stubs are cheap, so you can create a new stub with a deadline when you are making each RPC.

b...@soliduslink.com

unread,
Mar 20, 2018, 6:32:03 PM3/20/18
to grpc.io
Thanks! Does deadline actually mean the lifespan of a stub? If so I got it all wrong. I thought it's just the waiting time for each call invoked from that stub.

Is it recommended practice to create a new stub for each grpc call? Are there any docs stating that?
Reply all
Reply to author
Forward
0 new messages