-
Notifications
You must be signed in to change notification settings - Fork 3.9k
AndroidChannels: failing requests right after network recovery #5610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@AntKos Can you provide us the |
Sure thing:
By the way, a workaround for this is to return any big value from |
@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 Update: We will try to consistently reproduce the issue and dig into it. |
Previously I thought the issue get reproduced, but later I realized that the failed requests were due to remote service running on an unreachable network. Later, I tried with the loopback hostname ( I did all my testing on Android emulator. That's said, I cannot reproduce the issue you mentioned. I am suspecting this might be a device specific issue. So I would like you to do me a favor as the following:
|
I tried to systemize my observations, and here is what we have: I didin't test WiFi/Mobile networking switches, but if those are required - please write me. Did tests on three real devices and one emulator, all above API25 (as that is target API in our project for now).
Tests were started on fresh application run with enabled network by default. Host is remote. Detailed observations on Honor 10 Lite API 28 (Android 9):WiFi case: Mobile network case: The difference in mobile and WiFi cases is in network recovery part - it starts always before system starts What happens on Emulator(Nexus 6 API 27)WiFi case: works OK. My 5 cents are that when channel is |
Thanks so much for such a detailed observation! Now I got exactly the same behaviour as you said in emulator for mobile network. We will dig into it. |
For emulator: The above should only happen on emulators and would not occur on real devices. We will look into the behaviors on real devices later once we are able to test on physical devices. |
For your observation on physical devices under cellular network. At the moment you turn on mobile network (channel is in By the way, are you consistently getting the same behavior for IS520.1 API 25 (Android 7.1.2) devices under WiFi network? The above could also cause the same behavior (probably with fewer chances) even under WiFi network if refreshing the name resolution and channel state change are not completed before requests are initiated to send. We are currently thinking about if there are things we could do to reconcile this behavior. |
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. The follow properties we logged for the channel when the situation happened: Thanks. |
@sailat Our foreground service send request every 5 minutes, it seems the connection for grpc does not break when enter doze mode, after a while (~2 hour) the connection just lost but the application didn't know that. Thus, the reconnection never happens since the |
Currently, we just recreate an |
I also encountered a similar problem. Is it going to solve this problem? |
Yes, it is still in our bug list and we had brief understanding for this issue, while we are currently working on more prioritized issues. PRs or any debugging setup to easily reproduce the issue is welcome. |
hello i also encountered a similar problem. how do you handle it ? |
@jworldexpo Just new a channel when error occurs and retry... |
@jworldexpo, @hijamoya You may want to try with 1.34.0 release (the release may have other issues that affect you, see release note. Or you can wait for the soon-to-be-release 1.34.1), we had some change that intend to fix this issue. Please let us know if the problem persists. |
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 overAndroidChannel
. We expect to see successful network calls at that pointWhat 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 viaOkHttpClient
- and they work well. Additional digging in logs and debugging reveals, that this might be related toDnsNameResolver
, 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.
The text was updated successfully, but these errors were encountered: