Description
What version of gRPC are you using?
1.9.0
What did you expect to see?
For the grpc channel to be able to handle Android connectivity changes (eg. from wifi to mobile data, or from no data connection to wifi).
For the resetConnectBackoff()
call on a channel to successfully short-circuit the backoff timer and make it reconnect immediately when triggered from a connectivity change.
What did you do
Built a grpc channel using the OkHttpChannelBuilder
. Registered an Android BroadcastReceiver
against connectivity changes which calls the channels resetConnectBackoff()
(as recommended in #4011).
What did you see instead
The resetConnectBackoff()
being called from the broadcast receiver event (for android.net.conn.CONNECTIVITY_CHANGE
) and failing to short-circuit the backoff timer. Had to wait approx 60 seconds before the channel became usable again. Reports a host name resolution failure until the 60 seconds passes.
A sleep (of a few seconds) between the connectivity change and the resetConnectBackoff()
call seems to fix the issue.
Is there any way to decrease the default backoff time. It may be a useful feature in situations like this.