React-native, Firebase network error when trying to login

I have followed the tutorial on how to get into React-native using Firebase, I am using create-react-native-app for simple developer (my package.json ), I am using NodeJS v6.10.1

, I am using Note 4 device (4.4.4), I have included authentication by Email/Password

in Firebase console, for some reason I get:

{
    code: "auth/network-request-failed",
    message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred."
}

      

I didn't forget to use firebase.initializeApp

my code too :

firebase.auth().signInWithEmailAndPassword(email, password)
.catch(e0 => {
  console.log(e0);
  firebase.auth().createUserWithEmailAndPassword(email, password)
    .catch(e1 => {
      console.log(e1);
      this.setState({ error: 'Authentication Failed.' });
    });
});

      

For both, I get the same error object.

+5


source to share


3 answers


So the problem was:

It all starts with this Debugger and device times have drifted by more than 60s

, due to another adb related issue. I was unable to run adb shell "date -s

date +% m% d% H% M% Y.% S "

after I fixed my adb problem, I run adb shell "date -s

date +% m% d% H% M% Y.% S "

, now the error is Firebase was saying such as timeout

, adb (my computer) time was -4min than device, so to fix, I changed the time on my computer, adding 4 minutes to match the device time.

I guess this was the problem, I am not a networking expert, so if someone can correct some of my assumptions, if something is wrong:



For the explanation, I just use unreal things ( reqTimestamp

, ...), but the concept is correct (I hope):

The device signed the request with a timestamp and timeout, for example reqTimestamp = 22:16

, reqTimeout = 22:17

, my device is connected via my wifi, so when a modem is connected to my computer, a basic check on my computer or internally a modem like: if(reqTimeout > timeNow) reject

, could prevent the request from even leaving my network, so Firebase will throw this generic error regarding the network issue.

+4


source


I was getting this same error for a reactive project running using expo on an Android device emulator (on Windows).

I know this will sound strange, but in my case, I was getting this error when using the internet from my phone hotspot. When I switched to my normal Wi-Fi internet connection, the error went away.



Hope this helps.

0


source


I got the same error. In my case this is caused by more than one ID for the same email in Firebase -> Authentication. Not sure why I have more than one entry for the same email, but after deleting all and logging in again. The problem is resolved.

0


source







All Articles