node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

"read ETIMEDOUT" issues

Open morley92 opened this issue 9 months ago • 2 comments

We've been seeing sporadic read ETIMEDOUT errors when making queries to our database. The traffic is fairly low, and the issue is seen in periods of very low activity i.e. overnight.

These are the particulars:

  • Node 22.14.0
  • Relevant npm dependencies
    • mysql2 - ^3.12.0
    • typeorm - ^0.3.20
    • @nestjs/typeorm - ^10.0.2
  • MySQL 8.0.40 on AWS RDS
    • Instance class db.t4g.large
    • No RDS proxy

All are on pretty standard config. We've tried setting some of these options but no success

connectTimeout: 30_000
connectionLimit: 40
maxIdle: 10
idleTimeout: 30_000

Are there any configuration options worth trying? AWS seems to suggest there are no issues on their end, very stumped!

morley92 avatar Mar 04 '25 09:03 morley92

Hi, I have seen something similar when using RDS mysql with IAM and a rarely used app. When I access the app after a longer period of time it attempts to create new connections but fails since the AWS token expires after 15 minutes.

I have this in my app pool setup but it does not seem to actually be keeping the connections alive:

connectionLimit: 2
enableKeepAlive: true,
keepAliveInitialDelay: 60000,

The amount of time until the issue occurs seems directly related to the MySQL wait_timeout setting so I think its an issue with enableKeepAlive not working.

Using :

  • Node v23.6.0
  • mysql2: ^3.11.3

and the same RDS MySQL setup as above

HarrisonFBG avatar Mar 06 '25 00:03 HarrisonFBG

same issues here. here is my settings:

waitForConnections: true,
connectionLimit: 30,
maxIdle: 10, 
idleTimeout: 60000, 
queueLimit: 0, 
enableKeepAlive: true,
keepAliveInitialDelay: 0, 

the client lost connection to the database. but can resume after restart the client.

Using:

  • "mysql2": "^3.11.5"

enteve avatar Mar 21 '25 10:03 enteve