Open petroniuchacz opened 3 years ago
I am facing the same issue only in android devices..
@petroniuchacz @UzairSun93 Please try again using 2.0.0-beta.4. My test case worked fine:
Existing uploads may restart from the beginning.
I'm having the same issue in my app on Android 30 emulator. If I remove the app from recently opened (quit, but not force stop) and if I leave the emulator locked - it'll eventually start failing to resolve the host in my background worker.
Then when I wake up the device, go to chrome - I can access the internet. And background worker will succeed in making HTTP request again, without needing to restart the app.
I think it might be battery optimization of sorts.
@Maxim-Mazurok please share details on your phone model and OS.
Sounds like this issue: https://eu.community.samsung.com/t5/galaxy-a-series/no-internet-when-i-lock-my-phone/td-p/1249349
The plug-in currently requires WiFi to function thus it makes sense this will stop when WiFi is gone (and the phone is in BG).
Disclaimer: I'm not using this plugin, just getting a similar error with my own code.
@ened I'm running on an Android Studio emulator.
Pixel 3a, API 30 (Android 11.0) x86: sdk_gphone_x86_arm-userdebug 11 RSR1.201013.001 6903271 dev-keys
I've checked the wifi policy:
.\adb.exe shell settings get global wifi_sleep_policy
2
and it's "Keep WiFi on during sleep: Always"
I've had Battery Manager On though. I've disabled it and will see how it goes.
More details about my code and symptoms are in this question: https://stackoverflow.com/questions/65535857/how-to-fix-unable-to-resolve-host-error-in-workerwrapper
By the way, I plan to abandon the idea of making HTTP requests using WorkManager, and instead move polling logic to the server. And the server will send data notifications to the phone using firebase, which probably should be a bit more reliable in my case. But now that I've said it, I realized that if there's no WiFi for WorkManager - there'll be no WiFi to receive notifications as well... Unless Android is disabling network access specifically for my worker, and not for notifications...
Update: I can confirm that now, with Battery Manager turned off I get network access in my worker reliably. So, it must be it, I guess.
Android 11.0, plugin 1.2.0 I'm starting several upload tasks of binary content at he same time, then I'm disabling the network connection. After restoring the connection, some of the tasks don't resume nor do they fail, but stay "frozen".
In this example, I'm starting 4 upload tasks: 86e68f15-94a1-477b-8cab-7ca8f08649d8 107ef792-e15e-452e-8dbf-9e8f479ec732 4b3e6478-7707-4c9f-8b76-8de0524f9931 448448dc-6bd1-4ae5-aea7-6dcb1d7b0feb
After I switch the network off and on, only 2 tasks resume: 86e68f15-94a1-477b-8cab-7ca8f08649d8 107ef792-e15e-452e-8dbf-9e8f479ec732