-
Notifications
You must be signed in to change notification settings - Fork 614
Firebase Realtime Database don't get update from wifi #1258
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
Thanks for reporting, @Thaina. From what I understand, Realtime Database works on mobile/cellular connection properly, but not on Wi-Fi connection. We usually mention to developers that the issue may be isolated to certain network providers that possibly blocks access to certain services. However, if this isn't the case, then there may be something else that is causing it. With that, I would like to ask for the following details in order for me to understand the issue further:
|
@aguatno On monday I try to build and find the log but cannot see anything related to firebase database. It just silence I have upgrade to 6.11 yesterday and will try to log and search for problem again soon But one thing I would like to report is, while realtime database face the problem from wifi. Firestore (I have alpha privilege) can listen to change from that wifi normally. Is there anything related to network connection system difference between these two library? |
This is the log that might be related |
@Thaina Thank you for sharing the logs. It looks like the error might be a fundamental issue with the device's network ( Can you let us know if this problem occurs on multiple devices? If so, would it be possible to share a reproduction for us that we could run on Emulator? |
@schmidt-sebastian I don't know which specific device have this problem except one samsung of my acquaintance I don't know detail about. And my own Nokia 7 plus This problem could occur in many router setting even though it could use internet normally and the most disturbingly confusion is, in the same wifi that cause problem to android, realtime database in ios of the same app still work under it properly And while RTDB won't work, at the same time in the same device that RTDB can't load anything, firestore could work properly So this issue is really specifically a problem of only RTDB android library in wifi |
Firestore and RTDB uses a very different networking stack. Firestore uses GRPC, whereas the RTDB used WebChannel which more heavily relies on Android's built in networking. If you are able to reproduce this somewhat reliable in an emulator, then we could probably come up with a reproduction. It's a bit tough to diagnose issues that point to issues with the DNS resolver from afar. |
Thank you for your information. Sadly I don't have times, so I would switch to firestore instead as of now it release unity SDK |
Is there any alternative to solve this problem? |
At this point, I don't see an obvious fix since this happens very low in the network stack. |
same problem help :( |
I've also encountered this problem before and only resetting the customer's router ended up working. Writes over wifi to another REST API were working during this period, but setValue() to my Firebase RTDB were not. I unfortunately don't have the logs from that period. |
Chiming in since this seems to be an issue in our usage of Realtime Database too. For years already, we have received support requests from Android app users who are not receiving data from RTDB. I've tried many things over the years to mitigate this, but never have found a way to fix the issue completely. Switching away from wifi usually fixes the situation. It's not a very widespread issue, but one that has been very hard to reproduce. Common symptoms include:
|
One thing I am going to try (which I already do in another version of my app, for different reasons) is to create a dummy keep-alive setValue() write to my RTDB every 5 minutes or so. I've never gotten a report from that version of my app that the connection has broken, so I am wondering if it has something to do with it. Update: I was actually able to reproduce this, or some version of this, it seems. I connected my test device to my phone's hotspot wifi connection and then turned off the LTE mobile data. I sent my setValue() request with an onComplete listener and the connection hangs. DatabaseError is never thrown. I then re-enable the mobile LTE data on my hotspot device - subsequent attempts also fail, DatabaseError is never thrown so the else statement never runs. I opened a browser and confirmed internet connection is present. Restarting the activity in the reconnected state did not help as well. The fix was to disable and re-enable wifi on the device. |
How long did you wait for the connections to recover? This would be useful for comparing to the socket connection timeouts. |
Hi Kato, I let the setValue() run twice and both times it recovered after around 18 minutes. I'm happy to email you the entire stacktrace if that's helpful, it looks like there's some relevant stuff going on there. |
@katowulf and I connected offline and this is expected behavior due to the Android OS basically neglecting to informing apps when the connection is restored. I can't say if this is the same exact issue the original poster and others faced, but in my case (Nexus 10 tablet, Android 5.1.1) it took around 18 minutes to reconnect to the socket and for the setValue() request to complete after an initial internet disconnect (when no change in wifi network connection occurs). Restarting the app or disabling and re-enabling wifi appears to fix it. |
I managed to get some additional info about this issue from one of our users: sees like that using an Android device on wifi over a certain wifi router/modem (Sagemcom F-3686ACv2) from a certain Finnish mobile carrier (DNA) caused Firebase's websocket connection to wss://s-usc1c-nss-256.firebaseio.com to not work. HTTP traffic worked normally through the same wifi. This issue was "solved" by rebooting or resetting the router. Unfortunately I don't have logs about this case. While the blame in this case falls to the router and/or carrier, it's very unfortunate that this happens for Realtime Database usage only. And it's weird that this seems to affect Android only. I wish I could even get an error from Firebase SDK in these cases (currently no callbacks are fired when connection does not work). Our usage of Realtime database is read-only. |
@korva The glimpse of the cause is in this comment #1258 (comment) "The network stack" that rely on underlying android network library is the root cause, there was many bug about networking in android OS itself, not only firebase but facebook SDK also suffer from another android networking library bug and google themselves never ever had publicly announcement to fix them FireStore use GRPC instead and they avoid those android bug |
I happen to have the same issue, after reading this thread I contact our clients experimenting this issue, I suggested to them to use their mobile data instead of their wifi and the app loaded the info. One of our clients have two phones, Samsung A30s and Huawei P20 pro, the 2 devices were connected to the same wifi router. The samsung is having the issue, the Huawei is not. |
Firebase support got back to me and in my case, after an initial internet connectivity disconnect occurs with device wifi remaining connected, the correct approach is to simply call |
Current status: Workaround: Call goOffline() followed by goOnline(). While calling goOffline/goOnline is a reasonable workaround until there's a fix, doesn't feel like clients should have to monitor and manage the connectivity; our SDKs should handle this. Locking discussion to save eng time answering ETA requests, but keeping this open as a bug for discussion and resolution. We'll update here when there is a status update or news of a fix. Until then, please use the workaround and assume there's no release date available. |
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Using realtime database change listener normally in android mobile with wifi connection. It work perfectly for most of the times. But it would eventually (2-3 days to 2-3 weeks) not be able to connect to firebase realtime database and get the realtime update, even if the PC of the same router still able to connect. I need to shut the wifi of my android to use mobile 4g network, or reset the router. Resetting router make it usable but eventually after a while it will fail again
I myself using unity. But there was already some people happen to face the same problem so I think it could be common to many people
https://stackoverflow.com/questions/52609349/couldnt-connect-to-firebase-database-via-wifi-but-connects-fine-with-4g-mobile
https://stackoverflow.com/questions/48340327/firebase-database-listeners-dont-work-on-android-with-wifi
Also, surprisingly, the web that use firebase still work in the same network state. So I think this problem is because native network library
I think the actual source of problem could be a problem of router setting. But that might be critical. Because realtime update could be fail for anyone in misconfig router (in workplace for instance) but it result in the whole app failed unknowingly to us. It could also be a critical feature of that app. Isn't it possible to have firebase native to have failsafe to fallback?
The text was updated successfully, but these errors were encountered: