最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React-native, Firebase network error while trying to log in - Stack Overflow

programmeradmin1浏览0评论

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.

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.

Share Improve this question asked Apr 17, 2017 at 19:26 Aviel FedidaAviel Fedida 4,1029 gold badges57 silver badges89 bronze badges 2
  • Try again now.. i have seen multiple times that you get random network errors which disappear after a while – Christopher Rivera Commented Apr 17, 2017 at 20:23
  • @ChristopherRivera I've tried, unfortunately same error. – Aviel Fedida Commented Apr 17, 2017 at 20:42
Add a ment  | 

4 Answers 4

Reset to default 6

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 -sdate +%m%d%H%M%Y.%S", after I fixed my adb problem I run adb shell "date -sdate +%m%d%H%M%Y.%S", now the Firebase error was saying: such as timeout, adb(my puter) time was -4min than the device, so to fix that I changed the time on my puter, 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 puter, a basic check on my puter 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.

I was getting this same error for a react-native project running using expo on an android device emulator(on windows).

I know this will sound weird but in my case I was getting this error when using internet from my phone's hotspot. When I switched to my normal wi-fi internet connection, the error went away.

Hope this helps.

I have the same error. In my case it caused by more then one identifier for the same email in Firebase -> Authentication. Do not know why I have more than one record for the same email, but after deleting all and login again. The problem is resolved.

I had the same issue. I connected to a VPN, the error went away.

发布评论

评论列表(0)

  1. 暂无评论