Resetting deadline on streaming RPC

47 views
Skip to first unread message

Robert Bielik

unread,
Apr 16, 2018, 8:31:45 AM4/16/18
to grpc.io
I have a streaming RPC that reports back a progress message to a client. Right now a deadline of 10 seconds is set, however, the time it takes for the RPC to complete might very well exceed 10 seconds. 

Questions:
1. Is there a way to reset the client context deadline timer when I receive a streaming message from the server ?
2. Should I have a deadline at all in a streaming RPC ?

Regards
/R

Eric Anderson

unread,
Apr 16, 2018, 6:24:09 PM4/16/18
to Robert Bielik, grpc.io
On Mon, Apr 16, 2018 at 5:31 AM, Robert Bielik <robert...@gmail.com> wrote:
I have a streaming RPC that reports back a progress message to a client. Right now a deadline of 10 seconds is set, however, the time it takes for the RPC to complete might very well exceed 10 seconds. 

Questions:
1. Is there a way to reset the client context deadline timer when I receive a streaming message from the server ?

No. There timeout is for the entire call. It isn't from the last point of "progress" or similar.

2. Should I have a deadline at all in a streaming RPC ?

For many streaming RPCs, yes. For long-lived RPCs or highly-variable RPCs, maybe not. But in that case you may want to make your own timeout mechanism and cancel the RPC if it seems things aren't going well.

In certain circumstances, like long-lived streaming RPCs, you may want to lean on keepalive to help detect connection breakages instead of deadlines (since the deadline would be far too large anyway). Although keepalive is point-to-point and not end-to-end; you would need to make sure any proxies and similar also have some sort of failure detection.
Reply all
Reply to author
Forward
0 new messages