firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.28k stars 580 forks source link

Continued WiFi / router / ISP issues with Firebase Android SDK #4076

Open derrickrc opened 2 years ago

derrickrc commented 2 years ago

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

This is related to the following bugs: https://github.com/firebase/firebase-android-sdk/issues/1258 https://github.com/firebase/flutterfire/discussions/5546 https://github.com/firebase/firebase-android-sdk/issues/3436 https://github.com/invertase/react-native-firebase/issues/2715

I have a production app using Realtime Database Android SDK and there are what seem to be increasing instances of users being unable to access RTDB using WiFi (probably having affected at least 20% of users).

Device has internet connectivity, but simply cannot connect to Firebase. This is affecting devices from Lollipop up through Android 10.

I have tested also with Firestore writes, and the same problem occurs - it's not isolated to RTDB.

When using a mobile hotspot, connection to Firebase is always instantaneous.

In the past, a router reset has solved it. However, sometimes the router reset didn't work, and instead we had to use a dedicated separate 2.4GHz router with DHCP disabled, plugged into their main router.

Now in recent weeks, I've found cases where even the second router workaround doesn't work and now my only possible workaround is to either fully migrate away from the Android SDK and simply hit the Firebase API using HTTP requests, or to migrate away from Firebase entirely.

Are any other users of the Android SDK facing similar issues? Are ISPs clamping down more in recent months / weeks for some reason? Is there any other workaround I'm missing?

Can the team either update the Tubesock library which this seems to be built on or can they update the Android SDK to fall back on http requests or long polling (like the JS SDK) when websockets fails?

Thank you.

google-oss-bot commented 2 years ago

I found a few problems with this issue:

argzdev commented 2 years ago

HI @derrickrc, thanks for the detailed explanation of your issue. This is an odd issue, from the looks of it, if it affects both Firestore and RTDB, and you haven't had any changes on your code(specifically changes on your Firebase SDK versions) when the issue occurred, then this definitely sounds like a backend problem. Just a thought, it might be due to a zonal failure or restricted location. But, I think it would be best if you reach out to our Firebase Support. They'll be able to assist you better, since they have visibility on your project details.

As for Tubesock library, I'll mark this issue as a feature request for now. So our engineers can take a look once they have the time. Thanks!

cherylEnkidu commented 2 years ago

HI @derrickrc,

Given the information you provided, firebase is unlikely the one having problems. RTDB and Firstore use different connecting ways so if you observe same behaviour on both products, it is possible the issue related to your internet connections.

derrickrc commented 2 years ago

Thank you both. I did raise this bug with Firebase support about a year ago, and their response was the same which was to point to a network issue.

That said, if you haven't already, please read https://github.com/firebase/firebase-android-sdk/issues/1258. Many have encountered this issue and there is no resolution, and while it seems it only occurs with certain routers / networks / ISPs, it specifically affects Android + Firebase SDK (iOS is unaffected) while devices still retain internet connectivity.

So to me even if the root cause a network issue, I wonder if any update to the SDKs can be made to mitigate this issue - for example, falling back on the HTTP layer / long polling if it encounters a websocket issue / error. Thank you.

wu-hui commented 2 years ago

Hey @derrickrc

There is a similar issue we have been working with grpc to resolve, and we might have a fix from grpc. I do not know if that will fix all of the connectivity problems, but I'll make sure to update this ticket with that fix is landed so folks can try out.

iLoveDocs commented 1 year ago

One more issue related to this: https://github.com/firebase/flutterfire/discussions/5708?

tom-andersen commented 1 year ago

Hi @derrickrc,

Are you still experiencing problem? If not, I would like to close this issue.

derrickrc commented 1 year ago

@tom-andersen thanks for checking in - unfortunately yes, this issue still occurs though more infrequently. Just last month we had to ship a customer a 2.4GHz WiFi access point specifically to fix this issue, as their own network / modem prevented the Android device from communicating with Firebase Realtime Database.

Qw4z1 commented 1 year ago

A bit off-topic, but as an FYI, I am currently in Indonesia and cannot connect to any of my firebase projects (region doesn't seem to matter) unless I use a VPN. This is true for both Android, iOS and Firebase Hosting, so I don't think it's a problem with this SDK specifically.

eranl commented 7 months ago

Another seemingly related issue: https://github.com/googleapis/python-firestore/issues/787

eranl commented 7 months ago

I had this issue connecting to firestore on both android and linux/python, and it seems to have been an issue with an old cable modem. It would go away temporarily on modem reboot, and seems to be gone completely with a new modem.

For reference, I never saw this issue on linux/java or windows/java, on the same network.