-
Notifications
You must be signed in to change notification settings - Fork 4k
🐛 [cloud_firestore] Android: Firestore cannot re-establish connection after some time (or change of network) #5855
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
These exceptions are observable if you change networks because the device is temporarily offline but it should reconnect without any issues. Are you able to reproduce this with a minimal project with just |
Hi @markusaksli-nc , I haven't tried with a minimal project. But may I ask what does it mean when you say that the device is temporarily offline? Does it mean that the device hasn't authorized app to access internet or the device itself is not online? Because I can confirm that the device is online, because all other apps work fine. I have enough time to test other apps, while my app is still trying to establish a connection. |
I just mean when the device is switching network providers it will temporarily not be able to connect because it is establishing a connection to the new network. This should clear up in only a couple of seconds though. Could you try to see if you can create a minimal complete reproducible code sample that just isolates the issue to some part of |
Hello, similar to #4305 ? |
Thanks @QuentinSc. Infact, I read through the ticket and the behavior people have described, I am facing the exact same problem. The issue is not only limited StteamBuilder however, it also happens to all get() queries as well. Thanks for linking the tickets. |
Yep @frankyvij, I confirm what you are saying. |
If it's the exact same issue we can close this as a duplicate. |
Bug report
Describe the bug
Technically, I am not 100% sure if the issue is caused by cloud_firestore, or in fact if it is caused by the combination of workflows within firestore.
My users have complained that the Android app keeps losing connection to the firestore snapshot (as well as individual document.get() queries) after they switch from mobile data to WiFi. Even if they continue to stay on the same network, but keep the application in the background, when they open the app again - the connection is lost.
Steps to reproduce
I would like to highlight that the device is not offline. The device is in fact online, and I can confirm with various other applications installed on the same device. The issue is very easily reproducible and happens frequently on Android. I have not received any reports of such errors from iOS users (using the same code-base). The problem occurs in a couple of these scenarios:
When you change your device network. If you are on mobile data and switch to WiFi (or vice versa), chances are that all firestore calls will fail. All my users are reportedly restarting the app when this happens. Also, please note that this has only been observed on Android.
When you keep the app alive in the background. If the user opens the app after a while, the app will fail to connect to firestore. After about 20-25 seconds, firestore connection finally gets established, and then everything comes back to normal.
Expected behavior
Firestore should not lose connection and all snapshots and get queries should still be successful after network change/open the app after a while from the background.
Additional context
These are the logs that I have been able to capture. Note how the application is trying to re-establish the connection and it keeps failing. After multiple retries, towards the end, the connection is established and everything works fine. The logs are not complete, and only show you the last 14 seconds of interaction before the connection is successfully re-established. Actual duration was well more than 30 seconds before the user could re-establish the connection.
I am surprised that this issue is not reported by other Flutter users, is there something wrong with my setup?
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
The text was updated successfully, but these errors were encountered: