DNS resolution failure on Android after connectivity changes
See original GitHub issueWhat 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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
Update: #4105 changes the behavior of the gRPC library to use exponential backoff on dns resolution failures. This fixes the issue reported here, as the channel will recover ~immediately from a momentary failure in the dns resolver. This behavior change is automatic and doesn’t require any user action to enable. The fix is in master now and will be in the upcoming gRPC Java 1.11.0 release.
This will be resolved when https://github.com/grpc/grpc-java/pull/4105 is merged.