[Android Firestore] Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
My environment
- Android Studio version: 3.6.1
- Firebase Component: Firestore, Auth
Describe the problem
App always takes more than 1 minute to login, after login it cannot load firestore data. I checked the logs shown as below:
--------------------------Firebase logs--------------------------- W/Firestore: (21.5.0) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
. The logs tell that "device does not have a healthy internet connection at the moment", however I'm sure that my WiFi connection is strong, I can play something with youtube. . I searched on Stackoverflow and saw the guy having same my issue here but no answer till now (issue only when I using WiFI. If I change to Cellular then issue gone) https://stackoverflow.com/questions/62688604/firestore-android-sdk-cannot-reach-backend-server-on-android-9-and-other-version
Relevant issue:
. I searched in Github and saw there is same problem in firebase-js-sdk, and on this has a workaround solution by set the experimentalForceLongPolling=true. https://github.com/firebase/firebase-js-sdk/issues/1674
. However Android doesn't this option experimentalForceLongPolling, so how to solve this problem?
Gradle file:
implementation 'com.google.firebase:firebase-firestore:21.5.0'
implementation 'com.google.firebase:firebase-auth:19.3.2'
implementation 'com.firebaseui:firebase-ui-firestore:6.2.1'
implementation 'com.firebaseui:firebase-ui-auth:6.2.0'
I sense this may be a problem better suited for support or firebase-talk. Please reach us through those channels to get better help.
Did you figure out what the issue was, or a possible workaround? It sounds like the occasional behavior I see on my app' https://github.com/firebase/firebase-android-sdk/issues/1790
I am also facing same issue. In my case the error is only on android. My code looks like
let user = firebase.auth().currentUser;
firebase
.firestore()
.collection("users")
.doc(user.uid)
.get()
.then((doc) => console.log(doc.data()))
.catch((error) => console.error(error));
The error is
[Sun Aug 16 2020 01:38:11.623] ERROR [2020-08-15T20:08:11.107Z] @firebase/firestore: Firestore (7.17.2): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
[Sun Aug 16 2020 01:38:11.683] ERROR FirebaseError: [code=unavailable]: Failed to get document because the client is offline.
Surprisingly the same code works if I create the project using expo. Any clue where exactly I am missing?
Hey guys, were you able to fix this? I am also stuck on same issue, I have integrated the Firestore in Unity.
I tried some ways like change the Wi-Fi network then sometimes issue is gone. But I'm not sure this is the good way.
No, that's not a solution. Even for me it worked on a different 4g network n wifi but not on my phone's network. This is really strange but it has to be fixed. There will be a lot of people using our apps on different networks, they might face the same issue, better to apply a proper fix.
since this issue is closed, better follow it up here: https://github.com/firebase/firebase-android-sdk/issues/1790