Node.js AWS Cognito SignIn延迟太高
我正在使用aws cognito注册和登录我的应用程序。我的应用程序后端托管在aws lambda上,前面是我的api网关支持的api。例如,我使用“amazon cognito identity js”库并在后端从我的nodejs lambda调用注册。我向用户公开的api是/user/login 我的后端lambda调用登录中的代码如下:Node.js AWS Cognito SignIn延迟太高,node.js,authentication,aws-lambda,amazon-cognito,Node.js,Authentication,Aws Lambda,Amazon Cognito,我正在使用aws cognito注册和登录我的应用程序。我的应用程序后端托管在aws lambda上,前面是我的api网关支持的api。例如,我使用“amazon cognito identity js”库并在后端从我的nodejs lambda调用注册。我向用户公开的api是/user/login 我的后端lambda调用登录中的代码如下: exports.signIn = (email, password) => new Promise((resolve, reject) =&
exports.signIn = (email, password) =>
new Promise((resolve, reject) => {
const authenticationDetails = new Cognito.AuthenticationDetails({
Username: email,
Password: password
});
const cognitoUser = new Cognito.CognitoUser({
Username: email,
Pool: userPool
});
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: result => {
resolve({
data: {
token: result.getIdToken().getJwtToken(),
refreshToken: result.getRefreshToken().getToken()
}
})
},
onFailure: err => {
console.log(err);
reject({
data: {
errorCode: err.code,
errorMessage: err.message
},
statusCode: 400
})
}
});
});
API工作正常,正如预期的那样,我能够拿回令牌
我面临的问题是该API的高延迟。延迟大约为5-8秒,这太高了。我已经测试过,这种高延迟不能归因于lambda冷启动
有人能帮我理解为什么am的延迟如此之高吗?您的Cognito和API网关在同一地区吗?