node-mysql2
node-mysql2 copied to clipboard
ETIMEDOUT occuring multiple times in node script then moves on.
Here is my DB Connection
var mysql = require('mysql2'), // mysql2
// MYSQL Connection Info:
var db_config = {
connectionLimit: 10,
waitForConnections: true,
host: 'a.server.our.in.the.cloud.us-west-2.rds.amazonaws.com',
port: '3306',
user: 'XXXXXXXX',
password: 'XXXXXXXX',
database: 'DB'
};
var connection = mysql.createPool(db_config);
connection.on('error', function(err){
console.error('mysql Error', err);
});
Literally (half - 1) of my pool connections timeout about 2-5 minutes after starting my script with the error:
{ Error: connect ETIMEDOUT
at PoolConnection.Connection._handleTimeoutError (C:\nodeCode\FTPWatcher\node_modules\mysql2\lib\connection.js:188:13)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
fatal: true }
When I had 100 for my connection pool 49 Errors, When I have 50 connections, 24 Errors, when I did 10, 4 errors. Did The rest of the pool connect successfully? What about the queries that initiated the connection from my pool? Did they die to never reach my DB?
Version of mysql2 I am using [email protected] node v 6.11.0
Interesting Can you enable debug? It feels that 2x as much connections actually trying to connect ( or maybe increment connected queue length, idk ), very curious about 49 / 24 / 4 numbers
Do you have correct security group settings ( e.i are you able to connect from the same box using some other client - mysql cli / mysql workbench etc ) ? Is another half able to perform query?
We are able to connect using heidi sql from the same box with the connection information the same, without any issues.
Also, the pool re-establishes the connections about 1 minute later and the script continues running as normal and expected after that reconnect.
Could this be related to: https://github.com/sequelize/sequelize/issues/7884
Having connection issues with mysql boxes via sequelize on aws rds
Have had the same problem over a number of months, happening on rare occasions after first turning machine on and with the same project(s). It has been intermittent, note no change whatsoever to db cfg, sometimes rebooting machine cleared it.
Happened again today, running with debug: true gave:
Add command: ClientHandshake
Error: connect ETIMEDOUT
at PromisePool.query (d:\apps\C5_Group\node_modules\mysql2\promise.js:330:22)
at runQuery (d:\apps\C5_Group\csl\server\db\mysql\db.js:33:44)
at C5Cache.init (d:\apps\C5_Group\_shared\server\cache.js:26:10)
...
at Object.<anonymous> (d:\apps\C5_Group\C5\server\app\c5.js:60:14)
at Module._compile (internal/modules/cjs/loader.js:1147:30) {
message: 'connect ETIMEDOUT',
code: 'ETIMEDOUT',
errno: undefined,
sqlState: undefined,
sqlMessage: undefined
}
Changed host from localhost to 127.0.0.1 and it was able to connect ok! Changed it back to localhost and nogo. Note that localhost was fine most of the time just occasionally this error cropped up
Changed host from localhost to 127.0.0.1 and it was able to connect ok!
could it be some local resolver or system dns issues? @tomcon could you try to reduce to a simplest node tcp client and see if you have similar issues?
@sidorares did 2 tests using localhost and ip for both server and client & localhost version was waiting for 20 secs, interestingly both tests caused a SERVER CONSOLE.LOG: onerror Error: read ECONNRESET (in response to the first client.write() I think). ran client a second time and ok
Rebooted and all ok again but I think it might have been related to - surprise, surprise - antivirus software as AVG had a "quiet" update it applied on the reboot too
@sidorares had the problem again a little earlier (nothing to do with AV it seems this time) but changing cfg to 127.0.0.1 from localhost fixed it immediately
i am feed up from this , what would be the solution , i use localhost and also ip address in the host variable. any solution
@Hassanjankhan can you try using ip address instead of localhost? The timeout might be caused by some delay in the dns system