当我使用与 aws-sdk-2.4.12 版本关联的所有 AWS Cognito 位登录我的应用程序时,我发现 authenticateUser() 函数大约需要 14 秒才能完成。 (这种缓慢的响应行为并不新鲜——之前的版本也很慢。)
使用 Fiddler2,在将隧道发送到“cognito-idp.us-west-2.amazonaws.com:443”之前似乎用完了 6 秒,然后在 8 秒后调用成功完成。
问题是:为什么这么慢,有什么办法可以加快速度吗?
这是我的代码:
// Login
self.loginUser = function (username, password) {
var authData = {
Username: username,
Password: password
};
var authDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authData);
var userData = {
Username: username,
Pool: self.userPool
};
cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
cognitoUser.authenticateUser(authDetails, {
onSuccess: function (result) {
console.log('loginUser: ' + username);
},
onFailure: function (err) {
console.log(err);
console.log('FAIL loginUser: ' + username);
}
});
}
最佳答案
我的错。这是没有问题的。这是我在 Visual Studio 2015 中调试代码的神器。
以下是每个浏览器的登录计时结果,在桌面 Win7x64 上运行。
登录时间:
- Firefox:1.5 秒
- Chrome:2 秒
- IE 11:3 秒
- 使用 VS2015 调试 IE 11:14 秒
这是我第一次注意到 VS2015 显着影响 javascript 性能。有人知道为什么吗?
关于javascript - AWS 认知 : Why does authenticateUser() take 14 seconds to complete?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38776716/