简体   繁体   中英

AWS Lambda timeout

I have an AWS Lambda function that connects to SQL DB and the timeout for lambda has been set to 120 seconds. But when there is some issue with the DB connection or query execution, lambda is getting timed out after 60 seconds. Below is my DB config. I used node-mssql module.

const DBConfig = {
    user: Config.DBUser,
    password: pswd,
    server: Config.DBHost,
    port: Config.DBPort,
    database: Config.DBName,
    connectionTimeout: 60000,
    requestTimeout: 60000,
    options: {
        encrypt: false
    }
}

这是因为您的连接在尝试连接到数据库时超时,并且您没有在 lambda 函数内正确处理超时,并且您的 lambda 将超时。

Lambda can not get timed out before its duration exceeds the configured timeout value. Other options for the execution termination are: - The handler function has finished. - An unhandled exception was raised. In NodeJS specifically, the error message in the Lambda logs will be: 'process exited before completing request' (though it doesn't mean that there was a timeout). - There is an out of memory problem, but this doesn't seem like your problem.

Have you tried to increase the memory of your lambda function? In the past, when I bumped up the memory to 1GB+ this seems to have solved a number of connection problems for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM