Skip to content Skip to sidebar Skip to footer

What's Up With Firebase ".info/connected"?

According to the answer below, we need to read from the database to be able to trigger '.info/connected' ; https://stackoverflow.com/a/53222060/12755203 I am trying to use this '.i

Solution 1:

It's not very helpful to just query it a single time. A more helpful implementation would be to add a listener (as shown in the documentation) to that location so your code can be updated as soon as a change in connectivity is known. Your app can respond to these changes as needed.

You should also be aware that changes in connectivity can take some time to reflect in .info/connected. Slow or flakey connection will not necessarily cause changes to .info/connected. If the user's device loses connectivity for some reason, .info/connected will not necessarily reflect that immediately. It will take some time for socket operations to time out before Android declares that the connection is definitely gone. There is really no way around this fact - it's not always possible to tell a lost connection from one that's simply laggy.

.info/connected is good for reflecting the user the general state of the connection, but since it can be delayed, it shouldn't be considered an indicator that the next query will definitely complete immediately due to connectivity.

Solution 2:

The .info/connected node in the Firebase Realtime Database client indicates whether the client is connected to the Firebase Realtime Database servers. This requires much more than just having an internet connection, which is also the reason the .info/connected value is false for some time after the app starts, even if your device already has an internet connection.

Solution 3:

I called firebase.database().goOnline() some time before I started listening on .info/connected. Depending on your application, you may want to do it when your application starts.

Post a Comment for "What's Up With Firebase ".info/connected"?"