Aws lambda axios调用API时,AWS Lambda函数有时会出错
调用API时,我的Lambda函数有时返回错误。(Lambda同时调用2个不同的API) 非常有趣的是,我在启动API调用之前放置了一些console.log,但当Lambda启动时,它会立即返回错误,而不会打印任何日志,并且会出现2种类型的错误:Aws lambda axios调用API时,AWS Lambda函数有时会出错,aws-lambda,aws-api-gateway,aws-certificate-manager,Aws Lambda,Aws Api Gateway,Aws Certificate Manager,调用API时,我的Lambda函数有时返回错误。(Lambda同时调用2个不同的API) 非常有趣的是,我在启动API调用之前放置了一些console.log,但当Lambda启动时,它会立即返回错误,而不会打印任何日志,并且会出现2种类型的错误: { “errorType”: “Runtime.UnhandledPromiseRejection”, “errorMessage”: “Error: socket hang up”, “trace”: [ “
{
“errorType”: “Runtime.UnhandledPromiseRejection”,
“errorMessage”: “Error: socket hang up”,
“trace”: [
“Runtime.UnhandledPromiseRejection: Error: socket hang up”,
” at process.<anonymous> (/var/runtime/index.js:35:15)“,
” at process.emit (events.js:310:20)“,
” at processPromiseRejections (internal/process/promises.js:209:33)“,
” at processTicksAndRejections (internal/process/task_queues.js:98:32)”
]
}
{
“errorType”: “Runtime.UnhandledPromiseRejection”,
“errorMessage”: “Error: Client network socket disconnected before secure TLS connection was established”,
“trace”: [
“Runtime.UnhandledPromiseRejection: Error: Client network socket disconnected before secure TLS connection was established”,
” at process.<anonymous> (/var/runtime/index.js:35:15)“,
” at process.emit (events.js:310:20)“,
” at processPromiseRejections (internal/process/promises.js:209:33)“,
” at processTicksAndRejections (internal/process/task_queues.js:98:32)”
]
}
注5:
我可以随时访问API bu url(正如我现在测试的那样,响应没有问题,但可能10分钟后)
返回错误,谁知道呢)但我开始在AWS面板的Api网关中进行测试,有时会出现以下错误:
{
"errorType": "Runtime.UnhandledPromiseRejection",
"errorMessage": "Error: read ECONNRESET",
"trace": [
"Runtime.UnhandledPromiseRejection: Error: read ECONNRESET",
" at process.<anonymous> (/var/runtime/index.js:35:15)",
" at process.emit (events.js:310:20)",
" at processPromiseRejections
(internal/process/promises.js:209:33)",
" at processTicksAndRejections
(internal/process/task_queues.js:98:32)"
]
}
转换前的端点响应正文:{“Message”:null}
我不确定Lambda是否是一个稳定的平台
在这个Lambda中,我使用ExpressJS和Sequelize作为ORM。好的,这里有两个不同的问题:
- Lambda包装整个应用程序并开始处理诸如承诺错误之类的错误
- 另一个问题是表示API的Lambda函数(通过Sequelize从RDS中提取数据,并返回为JSON)。我们仍然收到消息:null错误,但我认为这一定与连接计数到RDS或非关闭的mySQL连接有关
- Lambda包装整个应用程序并开始处理诸如承诺错误之类的错误
- 另一个问题是表示API的Lambda函数(通过Sequelize从RDS中提取数据,并返回为JSON)。我们仍然收到消息:null错误,但我认为这一定与连接计数到RDS或非关闭的mySQL连接有关
- 好的,这里有两个不同的问题:
'use strict'
console.log("in APP 1");
const awsServerlessExpress = require('aws-serverless-express');
console.log("APP 2");
//express app
const app = require('./start-server');
console.log("in APP 3");
const binaryMimeTypes = [
'application/json',
'text/html',
];
console.log("in APP 4");
const server = awsServerlessExpress.createServer(app,null,binaryMimeTypes);
console.log("in APP 5");
exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context)