我有一个问题,在过去的3天与3%的请求,我们的lambdas。
它们由于与其他aws服务的连接超时而失败。请参阅同一lambda init中的堆栈跟踪
2021-10-30T16:37:33.310Z 7954e15a-8ae7-491e-880b-f5b532bde961 INFO TypeError: Unable to generate certificate due to
RequestError: Error: connect ETIMEDOUT 52.4.211.23:443
at /var/task/node_modules/cognito-express/lib/strategy.js:42:23
at bound (domain.js:416:15)
at runBound (domain.js:427:12)
at tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:725:18)
at _drainQueueStep (/var/task/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/var/task/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/var/task/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:464:21)
at process.topLevelDomainCallback (domain.js:147:15)
at process.callbackTrampoline (internal/async_hooks.js:129:24
2021-10-30T16:44:18.380Z 25392661-b635-4b73-9aed-67e655f13364 ERROR Unhandled Promise Rejection
{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "SequelizeConnectionError: connect ETIMEDOUT",
"reason": {
"errorType": "SequelizeConnectionError",
"errorMessage": "connect ETIMEDOUT",
"name": "SequelizeConnectionError",
"parent": {
"errorType": "Error",
"errorMessage": "connect ETIMEDOUT",
"code": "ETIMEDOUT",
"errorno": "ETIMEDOUT",
"syscall": "connect",
"fatal": true,
"stack": [
"Error: connect ETIMEDOUT",
" at Connection._handleTimeoutError (/var/task/node_modules/mysql2/lib/connection.js:189:17)",
" at listOnTimeout (internal/timers.js:557:17)",
" at processTimers (internal/timers.js:500:7)"
]
},
"original": {
"errorType": "Error",
"errorMessage": "connect ETIMEDOUT",
"code": "ETIMEDOUT",
"errorno": "ETIMEDOUT",
"syscall": "connect",
"fatal": true,
"stack": [
"Error: connect ETIMEDOUT",
" at Connection._handleTimeoutError (/var/task/node_modules/mysql2/lib/connection.js:189:17)",
" at listOnTimeout (internal/timers.js:557:17)",
" at processTimers (internal/timers.js:500:7)"
]
},
"stack": [
"SequelizeConnectionError: connect ETIMEDOUT",
" at ConnectionManager.connect (/var/task/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:126:17)",
" at processTicksAndRejections (internal/process/task_queues.js:95:5)",
" at async ConnectionManager._connect (/var/task/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:318:24)",
" at async /var/task/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:32",
" at async ConnectionManager.getConnection (/var/task/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:280:7)",
" at async /var/task/node_modules/sequelize/lib/sequelize.js:613:26",
" at async MySQLQueryInterface.select (/var/task/node_modules/sequelize/lib/dialects/abstract/query-interface.js:953:12)",
" at async Function.findAll (/var/task/node_modules/sequelize/lib/model.js:1753:21)",
" at async /var/task/src/routes/root/index_routes.js:20:18"
]
},
"promise": {},
"stack": [
"Runtime.UnhandledPromiseRejection: SequelizeConnectionError: connect ETIMEDOUT",
" at process.<anonymous> (/var/runtime/index.js:35:15)",
" at process.emit (events.js:412:35)",
" at process.emit (domain.js:470:12)",
" at processPromiseRejections (internal/process/promises.js:245:33)",
" at processTicksAndRejections (internal/process/task_queues.js:96:32)"
]
}
下面是mysql初始化代码
if (global.sequelize != null) {
console.count('\x1b[32mRESERCH: connection exported from globals instead of creation\x1b[0m');
module.exports = global.sequelize;
} else {
console.count('\x1b[31mRESERCH: new connection created\x1b[0m');
global.sequelize = new Sequelize(
s.sqlDbName,
s.sqlUsername,
s.sqlPassword, {
host: s.sqlDbHost,
dialect: 'mysql',
// to print out the query + it's time
// check if causes performance issues
benchmark: true,
pool: {
max: 5,
min: 0,
idle: 10000
}
});
这只是一些请求,但它给我们的用户带来了很多错误。无法检测根本原因。
发布于 2021-10-31 14:23:33
似乎通过稍微更改λ的VPC就可以解决它有两个子网,public
和private
。已删除public
不知道为什么这么做。也许它会强制lambda从内部ip连接到db和cognito。
https://stackoverflow.com/questions/69780892
复制相似问题