question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AndroidChannels: failing requests right after network recovery

See original GitHub issue

What version of gRPC are you using?

1.20.0

What did you expect to see?

In our project we use android JobService, which starts right after device establish network connection. Inside that service we run Grpc request over AndroidChannel. We expect to see successful network calls at that point

What actually happens.

Most of the time, this request fails few times in a row (as JobService reschedules itself on failure). At first it seems that though JobService is started, no connection is available for some reason, but then we tried to add simple http request via OkHttpClient - and they work well. Additional digging in logs and debugging reveals, that this might be related to DnsNameResolver, as it might resolve address when request is already in progress. This issue seems highly related to #4028, but occurs in AndroidChannel.

Steps to reproduce

Given mentioned setup (JobService + AndroidChannel), it requires android device with API 24+. Issue can be reproduced by toggling off device internet connection (both WiFi and mobile, seems no difference), wait around 10-15 seconds, and toggling on connection. Example project, which can demonstrate this issue can be found at https://github.com/AntKos/android-grpc-jobservice.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
hijamoyacommented, Mar 27, 2020

I faced a similar issue, say we have a foreground service which always running on the phone, then we turn off screen and wait a period (~4 or 5 hours) until the device enter doze idle mode. After that, we turn on the screen and the foreground service can not send any request by the AndroidChannel (but the rest api by retrofit is still working), the only way to recover is to turn off then turn on the wifi to make the channel reconnect again.

The follow properties we logged for the channel when the situation happened: isShutdown: false isTerminated: false state: READY Where the AndroidChannel is a global singleton for the application.

Thanks.

2reactions
voidzcycommented, Apr 22, 2019

@AntKos I tried to run your example on Android emulator and it works for localhost (gonna try with some remote server later). Does this issue only occurs on physical devices? If it does, can you tell us the specific device model you tested on? Also, for the OkHttpClient used as comparison, have you ever tried a different target instead of “www.google.com” (as google.com is highly likely to be cached by DNS)?

Update: We will try to consistently reproduce the issue and dig into it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retrying failed network requests automatically on Android
Today I am going to review retrying other failed network requests automatically ... For example, one client may retry the operation after 2, ......
Read more >
HTTP request fails even if the connection is active
In Android all works without that http request. After that that http request is made, all others fail after timeout with UnknownHostException ...
Read more >
Question - Flashed 13, can't go back to A12 and now soft bricked
... and now soft bricked - HEAD request failed: Unknown network error ... error or does anyone have a solution on how to...
Read more >
Service status - IBM
Attempting recovery: Services that encountered a problem and for which the server is attempting to process a previously blocked request. Locked: Services that ......
Read more >
Transactional requests and failure recovery in database systems
However, we would just have moved the race-condition a bit further, considering that a network partition could lead the client receive the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found