skip to Main Content

I was testing my iOS app and continuously fetching data and decided to hop off my Wifi with the app still open and test it on LTE. In my debug logs I see this error "[FirebaseFirestore][I-FST000001] WatchStream (10d119db8) Stream error: ‘Unavailable: Network connectivity changed’" being printed. The fetching of the data no longer works and not because my LTE is too slow. I prove this because it seems to regain connection and fetching of the data works fine if I kill the app and reopen it (tested this many times). I can’t seem to find anywhere online on how to reconnect/refresh a connection to Firestore on a network connectivity change like this one. Anybody got any ideas?

2

Answers


  1. Chosen as BEST ANSWER

    After more research, I learned Firestore attempts to reestablish a connection on it's own. I was testing other features in my app to see if this was true and it was! The other features were working.

    So i decided to look elsewhere in my code and discovered I was not properly handling a condition where my data was not being cleared before a reload of the table. This was happening I suppose due to the auto Firestore data caching when losing a connection? In order to reload the table the data needed to be cleared first. So it was a bug in my code completely unrelated to the network connection.


  2. The error message that you have mentioned clearly states an issue with the connectivity changes that the Firebase app is not able to keep up while loading data and switching networks during this.Though Firebase apps automatically handle temporary network interruptions. Cached data is accessible while offline and Firebase resends any writes when network connectivity is restored.Add a listener to the Firestore client to detect when the connection status changes. You can then use the Firestore client’s reconnect() method to attempt to re-establish the connection to the Firestore server. Additionally, you can also use the onReconnect() method to register a callback that will be called when the Firestore client successfully reconnects to the Firestore server.

    Also check the following documentation for your reference:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search