'Offline Firestore : Stream closed with status: Status{code=UNAVAILABLE

I am getting those error messages when I am using my App offline (it is working when I am online):

W/Firestore(23675): (24.0.1) [WatchStream]: (da69cba) Stream closed with status: Status{code=UNAVAILABLE, description=End of stream or IOException, cause=null}. W/Firestore(23675): (24.0.1) [WriteStream]: (9780b0d) Stream closed with status: Status{code=UNAVAILABLE, description=End of stream or IOException, cause=null}. W/Firestore(23675): (24.0.1) [WriteStream]: (9780b0d) Stream closed with status: Status{code=UNAVAILABLE, description=Unable to resolve host firestore.googleapis.com, cause=java.lang.RuntimeException: java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname

Here is my main.dart :

  await Firebase.initializeApp();
  FirebaseFirestore.instance.settings = Settings(cacheSizeBytes: Settings.CACHE_SIZE_UNLIMITED);
  FirebaseFirestore.instance.settings = Settings(persistenceEnabled: true);

What did I miss ? (I have the last version of flutter and cloud_firestore package)

Is it because I am in debug mode using Android Emulator ?



Solution 1:[1]

It could be a server error or it could be related to this issue on Github.

As you can see the issue on Github is still open and under investigation, if you can update to the latest version of flutter.

For the UNAVAILABLE Firebase ErrorCode documentation says:

UNAVAILABLE (HTTP error code = 503) The server is overloaded.   The server couldn't process the request in time. Retry the same request, but you must:
- Honor the Retry-After header if it is included in the response from the FCM Connection Server.
- Implement exponential back-off in your retry mechanism. (e.g. if you waited one second before the first retry, wait at least two second before the next one, then 4 seconds and so on). If you're sending multiple messages, delay each one independently by an additional random amount to avoid issuing a new request for all messages at the same time. Senders that cause problems risk being denylisted.

Check here for more about Error codes

Also,basic but worth a test, make sure that the device connection is stable with no drops.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1