Android/FireBase Series: [#04] — FirebaseNetworkException: A network error (such as timeout, interrupted connection, or unreachable host) has occurred

Leo N
2 min readMar 21, 2020

--

Error when fireBase got network problem

Why it happens?

1. Firebase documents

The maximum time in milliseconds. Defaults to 10 minutes (600,000 milliseconds).

2. Firebase SDK

3. Solution

The Firebase SDK for Cloud Storage is fault tolerant. It will retry and resume downloads that are in progress with the hope that network connectivity will return (which is common for mobile devices).

If you want to stop a download when network connectivity is lost, you’ll have to detect the loss of connectivity on your own, then cancel the download.

Uploads, Downloads and other operations are intended to automatically retry and shield you from temporary interruptions. There is a configurable timeout that will end (fail) the operation if it cannot transfer a packet in that time. You can set this with:

//if we get interrupted for more than 2 seconds, fail the operation.
FirebaseStorage.getInstance().setMaxUploadRetryTimeMillis(2000);

--

--

Leo N
Leo N

Written by Leo N

🇻🇳 🇸🇬 🇲🇾 🇦🇺 🇹🇭 Engineer @ GXS Bank, Singapore | MSc 🎓 | Technical Writer . https://github.com/nphausg

No responses yet