Client connection recovery

get_authenticated_channel() keeps its shared 900-second ping interval. Pass keepalive_time=None to disable transport keepalive. The optional keepalive_timeout sets a positive, finite acknowledgement timeout. It defaults to the supplied Configuration value, or 20 seconds. Both durations reject zero, negative, non-finite, and boolean values.

Clients can select keepalive_time=15, keepalive_timeout=10. An unacknowledged ping closes the transport within at most 25 seconds of a silent failure, subject to event-loop scheduling. Reconnect delay and authentication time are additional. A worker with a 5-second retry cap and 10-second authentication timeout can make its next connection attempt within 30 seconds and complete an available connection within 40 seconds. The broker’s normal session timeout is 60 seconds.

An outstanding getTask counts as an active call even when no work matches. Repeated pings therefore continue during a healthy long wait. By default, a channel with no active RPCs sends no pings. Set keepalive_permit_without_calls=True to probe such channels too. The caller must replace a failed authenticated channel and cancel its old work. A PING proves transport liveness, not broker application progress or assignment ownership.

A supplied config=Configuration(...) provides window sizes, TLS hostname settings, the acknowledgement timeout, and the idle-call policy. Explicit keepalive arguments override those policy values. keepalive_time always wins, including its default of 900. The helper permits unlimited pings without DATA and sets the minimum spacing to the smaller of one second and the ping interval. Confirm that the broker and intervening proxies permit your chosen ping rate. A peer that rejects frequent pings can close the connection instead.

Transport tests exercise silent loss, explicit disconnect, idle channels, and long RPCs over TCP, including certificate-verified TLS, against the installed grpclib version in the supported >=0.4.9,<0.5 range. The minimum excludes 0.4.7, whose stream reset after a TLS disconnect can raise AttributeError. Policy logs contain durations and flags, never authentication credentials. grpclib.protocol debug logging provides transport close reasons, including keepalive expiry.