Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: connect ETIMEDOUT (while connecting lambda to RDS) #132

Open
kashifaliquazi opened this issue Apr 5, 2022 · 0 comments
Open

Error: connect ETIMEDOUT (while connecting lambda to RDS) #132

kashifaliquazi opened this issue Apr 5, 2022 · 0 comments

Comments

@kashifaliquazi
Copy link

Hello Everyone,

We are using this plugin to connect the Lambda function to the RDS(Arora MySQL). Both Lambda function and RDS are in the Same VPC and in DB's security group inbound traffic is allowed from the whole VPC CIDR.

Some of the time the Lambda is getting timed out with the Below error, Most of the blogs say it is a network topology issue but Lambda is able to access DB most of the time. we face this issue only 2% of the time but it is still impacting the users.

we got the connection some of the times even after this error after retrying (Plugin internal retry mechanism) and some of the times the lambda times out after 2-3 retries.

Here is the code

` let db_config = {};
db_config.host =;
db_config.user =;
db_config.password =;
db_config.connectionLimit = 2;
db_config.multipleStatements = true;

let mysqlconnpool = require('serverless-mysql')({backoff:'decorrelated',base:5,cap:200,config:db_config,
onError:(err)=>{
console.log("mysqlconnpool_onError",err)
},
onConnectError:(err)=>{
console.log("mysqlconnpool_onConnectError",err)
},
onConnect:()=>{
console.log("mysqlconnpool_connected")
}});
module.exports = mysqlconnpool; `

let QueryResults = await mysqlconnpool.query(query); await mysqlconnpool.quit();

Here is the error we are getting:

Error: connect ETIMEDOUT
at Connection._handleConnectTimeout (/opt/node_modules/mysql/lib/Connection.js:409:13)
at Object.onceWrapper (events.js:420:28)
at Socket.emit (events.js:314:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at Socket._onTimeout (net.js:483:8)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
--------------------
at Protocol._enqueue (/opt/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/opt/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/opt/node_modules/mysql/lib/Connection.js:116:18)
at /opt/node_modules/serverless-mysql/index.js:99:16
at new Promise ()
at _connect (/opt/node_modules/serverless-mysql/index.js:93:14)
at connect (/opt/node_modules/serverless-mysql/index.js:68:13)
at /opt/node_modules/serverless-mysql/index.js:77:39
at async connect (/opt/node_modules/serverless-mysql/index.js:77:9)
at async Object.query (/opt/node_modules/serverless-mysql/index.js:182:5) {
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
fatal: true
}

Any help would be really appreciated.
Thanks in Advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant