Connection Health Check

115 views
Skip to first unread message

Tim McManamey

unread,
Dec 16, 2016, 12:55:49 PM12/16/16
to grpc.io
I'm using a bi-directional connection with StreamObserver.  I want to be able to check the status of the connection periodically and respond appropriately.  I know that netty will cache the data until a reconnect, but I don't want to do that.  I want to be able to discard the data until the connection is re-established.  I've seen many mention using pings, but I don't know how that works.  Thanks for any help.

Tim

Tim McManamey

unread,
Dec 16, 2016, 12:56:35 PM12/16/16
to grpc.io
I'm implementing this in Java.

Carl Mastrangelo

unread,
Jan 5, 2017, 8:51:05 PM1/5/17
to grpc.io
You can use waitForReady to shortcut RPCs.  It will fail them immediately if there is not a connection I believe.  You can set it on the CallOptions or the Stub. 

Kun Zhang

unread,
Jan 6, 2017, 1:43:15 PM1/6/17
to grpc.io
I think you meant "fail-fast", which is the opposite of wait-for-ready.

A wait-for-ready RPC will persist until it's sent to a server or meets its deadline.

Fail-fast means the RPC will fail if there is any connection-level error, which could be but no limited to name resolution error, connection refused, or handshake failed. However, RPCs will wait if connection is in progress.

Tim, the fail-fast behavior (which is the default) should work for you. Every connection failure will come back as a stream failure if you always create a new stream as soon as the previous one finishes.
Reply all
Reply to author
Forward
0 new messages