🐛 [CLOUD_FIRESTORE, FIREBASE_DATABASE, FIREBASE_AUTH ] FlutterFire Plugins causing issues on some networks
Bug report
Describe the bug At least three of the FireFlutter Plugins - Auth, Firestore and Database are not working on some mobile networks. The issue is independent of device but depends on SIM/Network, As when I run the app on my device on LTE Mode, the issues occur. But when I run the app after switching to 2G Mode(Same Device and Same SIM), the issue gets resolved. Also the issue doesn't occur on Wifi. Device - Redmi Note 8 Pro Service Provider - Airtel Country - India
The issue is not happening with all Airtel SIM. But occured on Vodafone 4G in Samsung s8+ as well.
The issue is explained below in Additional Context.
Steps to reproduce
Steps to reproduce the behavior:
- Create a new Flutter App
- integrate FlutterFire
- add fireflutter plugins in pubspec
- Try to read data from firestore/realtime database or add data in it.
- verifyPhoneNumber , sendOTP using Firebase PhoneAuth
Expected behavior
All I expected was to normally read the data saved in firestore/realtimedatabase, but its not happening unless I switch the network on some devices. Working as expected on other devices.
Additional context
When I use PhoneAuth, it takes minutes to send OTP. i.e., sendOTP callback is called after minutes. When I try to get/add Data from/to Realtime_database, I get No Response(neither the data nor any error). When I try to get Data from Firestore, I get No data but I get the following lines in terminal - W/Firestore(17877): (21.4.3) [OnlineStateTracker]: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds W/Firestore(17877): W/Firestore(17877): 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. E/flutter (17877): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: [cloud_firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.
Despite having a very Good Internet Connection (30Mbps on Ookla Speed Test). Service Provider- Airtel 4G Device - Redmi Note 8 Pro All these issues get resolved as soon as I switch to Airtel 2G or Wifi.
I tested on other devices which also use Airtel 4G, but they work fine. But if I connect those devices with my Wifi Hotspot, they start getting the above mentioned issues.
Working as expected on many devices/networks but not works on a few. I cannot notice any pattern in which devices or networks the issue is occuring.
I have also created fresh firebase project and flutter app twice, but the results are the same.
I also found a similar issue which was posted in June( Link) , So other people are also facing similar problem as me, but that issue wasn't described in detail and also not labelled as needs attention, so I had to raise a new Issue. I need help urgently.
I have to submit the application to my client, Please fix this ASAP or let me know approx how long will it take because this bug isn't letting me use firebase in my flutter application, because the plugins cause errors in 1 out of every 5 networks/devices.
Flutter doctor
Run flutter doctor and paste the output below:
Click To Expand
[√] Flutter (Channel stable, 1.20.2, on Microsoft Windows [Version 10.0.19041.508], locale en-IN)
• Flutter version 1.20.2 at C:\flutter_windows_1.20.2-stable\flutter
• Framework revision bbfbf1770c (5 weeks ago), 2020-08-13 08:33:09 -0700
• Engine revision 9d5b21729f
• Dart version 2.9.1
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\mali1\AppData\Local\Android\sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 48.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.49.1)
• VS Code at C:\Users\mali1\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.14.1
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
Flutter dependencies
Run flutter pub deps -- --style=compact and paste the output below:
Click To Expand
Dart SDK 2.9.1
Flutter SDK 1.20.2
testofflutterfire 1.0.0+1
dependencies:
- cupertino_icons 0.1.3
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
dev dependencies:
- cloud_firestore 0.14.0+2 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web]
- firebase_auth 0.18.0+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.5.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_database 4.0.0 [flutter firebase_core]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span
stream_channel string_scanner term_glyph typed_data]
transitive dependencies:
- async 2.4.2 [collection]
- boolean_selector 2.0.0 [source_span string_scanner]
- characters 1.0.0
- charcode 1.1.3
- clock 1.0.1 [meta]
- cloud_firestore_platform_interface 2.0.1 [flutter meta collection firebase_core plugin_platform_interface]
- cloud_firestore_web 0.2.0+1 [flutter flutter_web_plugins firebase http_parser meta firebase_core cloud_firestore_platform_interface js]
- collection 1.14.13
- fake_async 1.1.0 [clock collection]
- firebase 7.3.0 [http http_parser js]
- firebase_auth_platform_interface 2.0.1 [flutter meta firebase_core plugin_platform_interface]
- firebase_auth_web 0.3.0+1 [flutter flutter_web_plugins firebase meta http_parser intl firebase_core firebase_auth_platform_interface js]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.0 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- intl 0.16.1 [path]
- js 0.6.2
- matcher 0.12.8 [stack_trace]
- meta 1.1.8
- path 1.7.0
- pedantic 1.9.0
- plugin_platform_interface 1.0.2 [meta]
- quiver 2.1.3 [matcher meta]
- sky_engine 0.0.99
- source_span 1.7.0 [charcode collection meta path term_glyph]
- stack_trace 1.9.5 [path]
- stream_channel 2.0.0 [async]
- string_scanner 1.0.5 [charcode meta source_span]
- term_glyph 1.1.0
- test_api 0.2.17 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.2.0 [collection]
- vector_math 2.0.8
Under the hood we wrap the official SDKs, so we don't do anything in regards to non-default SDK functionality. I'd suggest raising an issue directly with Firebase.
But firebase is working normally with the native Android SDKs, as I have checked already with a native Java Android Application build without flutter, that is why I raised an issue here. Anyways I'll raise an issue directly with firebase as well.
Have you tried it with the exact same versions we're using? I have no idea why this would happen 🤔
I have used the latest versions of all the plugins - firebase_core 0.5.0 firebase_auth 0.18.0+1 firebase_database 4.0.0 cloud_firestore 0.14.0+2
I have already submitted the bug directly on Firebase as you directed. Let's wait for their reply, but I have a strong feeling that the issue is with FlutterFire.
Yes, due to this the presence system build with firebase also fails . This is causing an issue for me as well!
upon fetching data from the firestore, I am getting the same error
@itssidhere Could you expand on this, not sure what you mean but keen to fix it.
@Ehesp He might be talking about this: https://firebase.google.com/docs/firestore/solutions/presence
@Ehesp The presence system built with firestore as per official documentation fails on some network . It always sets the client offline on some networks. I have noticed this after 14.0.0
Using vpn fixes the issue so I don't know what exactly is going wrong on those client's devices.
Ah I see, that'll be because we've updated the internal SDK versions.
I'll see if I can get this pushed internally with Firebase.
Ah I see, that'll be because we've updated the internal SDK versions.
I'll see if I can get this pushed internally with Firebase.
@Ehesp , Will this also solve the issues with realtime database and Auth ?
Hi, I am also getting the same error with some networks. Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
Can you please let me know the solution for this issue?
Hi, I have the same issue for several days... but not solved yet. I found an interesting explanation here : https://github.com/firebase/firebase-js-sdk/issues/1674#issuecomment-706376914
I contacted Firebase support for this issue and found out it was a problem between some ISPs and Firebase... Day before I was informed the issue has been resolved, and my app also started working fine since last two weeks..
Ok thank u for the information. It's a really weird problem.
In my case the problem appears mostly when I turn on the device and then I launch the app. Firestore does not update data and I have the message [OnlineStateTracker]: Could not reach Cloud Firestore backend...
If I turn off the wifi on the device while the app is running and immediately after, I turn on the wifi then the Firestore connection comes back !
I tried a lot of situations but without finding the clear origin.
Last year, I made an app with Firebase Firestore. It's installed on the same device with the same network and I have no problem with this app. But in my new projects the problem appears...
The same issue here [Firestore] Could not reach Cloud Firestore backend over Wifi on physical device. #2753
I have the same issue for several days in Firebase Auth
Closing in favour of #2753.