1
发生网络错误(例如超时,连接中断或无法访问的主机)。使用Firebase API登录时出现超时错误
每当我尝试登录时总会发生此错误。
我的JS代码:
firebase.auth().signInWithEmailAndPassword(emailId, password).then(function (userData) {
usersRef.child(userData.uid).once("value", function (userSnap) {
var usersSnap = userSnap.val();
/*
* Record login attempt to firebase
*/
if (userSnap) {
authlogRef.child(userData.uid).once('value', function (userLogSnap) {
userLogSnap = userLogSnap.val();
// Initial login count
var loginCount = userLogSnap && userLogSnap.loginCount || 0;
// timestamp for current login
var timestamp = Date.now();
// log data to update
var data = userLogSnap || {};
//If no timestamps -> First login attempt, so timestamps -> []
if (!data.timestamps) {
data['timestamps'] = []
}
// push current timestamp for current login
data.timestamps.push(timestamp)
// increment login count
data['loginCount'] = loginCount + 1;
// set data to end point
authlogRef
.child(userData.uid)
.set(data)
.then(function() {
callback(null, usersSnap);
})
})
}
}).catch(function (error) {
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode == 'auth/invalid-email') {
var msg = 'Email id is not Valid';
callback(msg);
} else if (errorCode == 'auth/user-disabled') {
var msg = 'User is in disable state';
callback(msg);
} else if (errorCode == 'auth/user-not-found') {
var msg = 'User not found';
callback(msg);
} else if (errorCode == 'auth/wrong-password') {
var msg = 'Invalid Password';
callback(msg);
} else if (errorCode == 'auth/network-request-failed') {
var msg = 'Network Error';
callback(msg);
} else {
callback("error:" + errorMessage);
}
});
})
有时候,我得到超时错误。但我不能指出什么是错的。
嘿@ankit,你可以检查网络控制台,并提供什么是超时的细节,因为这可能发生的原因很多。 – bojeil
@bojeil感谢您的回复,错误越来越多的客户computer.I没有任何access.In在我的系统中正常working.Very罕见的情况下,我收到此错误 –