I've followed a React-native login tutorial using Firebase, I use create-react-native-app for easy dev(my package.json), I'm using NodeJS v6.10.1
, I'm using Note 4 Device(4.4.4), I enabled Email/Password
authentication within 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 forgot to use firebase.initializeApp
and my code is:
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.
So the problem was:
It all starts by this Debugger and device times have drifted by more than 60s
, due to other, adb related problem I couldn't 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 Firebase error was saying: such as timeout
, adb(my computer) time was -4min than the device, so to fix that I changed the time on my computer, adding 4min so it will match the device time.
What I assume was the problem, I'm not a networks expert so please if anyone can fix some of my assumptions if there is something wrong:
For explanation I just use unreal stuff(reqTimestamp
,...), but the concept is valid(I hope):
The device signed the request with a timestamp and a timeout, for example, reqTimestamp=22:16
, reqTimeout=22:17
, my device is connected throught my wifi, so when the modem connected to my computer, a basic check on my computer or internally the modem, such as: if(reqTimeout > timeNow) reject
, could prevent the request from even leave my network so Firebase issue this generic error regarding network problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With