[英]React-native, Firebase network error while trying to log in
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:我遵循了使用 Firebase 的 React-native 登录教程,我使用create-react-native-app来轻松开发(我的package.json ),我使用的是v6.10.1
,我使用的是 Note 4 Device(4.4 .4),我在 Firebase 控制台中启用了Email/Password
身份验证,出于某种原因,我得到:
{
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.initializeApp
,我的代码是:
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.这一切都由这个Debugger and device times have drifted by more than 60s
,由于其他与 adb 相关的问题,我无法运行adb shell "date -s
date +%m%d%H%M%Y.%S "
,在我修复了我的 adb 问题后,我运行adb shell "date -s
date +%m%d%H%M%Y.%S "
,现在 Firebase 错误说: such as timeout
, adb(my computer) time 是-4min 比设备,所以为了解决这个问题,我改变了我电脑上的时间,增加了 4min,这样它就会匹配设备时间。
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):为了解释,我只使用了虚幻的东西( reqTimestamp
,...),但这个概念是有效的(我希望):
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.设备使用时间戳和超时对请求进行签名,例如 reqTimestamp= 22:16
, reqTimeout= 22:17
,我的设备是通过我的 wifi 连接的,所以当调制解调器连接到我的计算机时,对我的计算机进行基本检查或在调制解调器内部,例如: if(reqTimeout > timeNow) reject
,甚至可以阻止请求离开我的网络,因此 Firebase 会发出这个关于网络问题的一般错误。
I was getting this same error for a react-native project running using expo on an android device emulator(on windows).对于在 android 设备模拟器(在 Windows 上)上使用 expo 运行的 react-native 项目,我遇到了同样的错误。
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.当我切换到正常的 Wi-Fi 互联网连接时,错误消失了。
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.在我的情况下,它是由 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.我连接到VPN,错误消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.