-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
Description
We are using pool.query
to query a MySQL database, but after running our website for a few hours we get an error:
Error: Connection lost: The server closed the connection.
at Protocol.end (/opt/node-v0.10.20-linux-x64/IM/node_modules/mysql/lib/protocol/Protocol.js:73:13)
at Socket.onend (stream.js:79:10)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
And our server can no longer connect to the MySQL database. We are using pools, so I thought the pool would automatically reconnect to the DB. Here's the code we use to create the pool:
pool = mysql.createPool({
connectionLimit : 10,
host : creds.mysql_host,
port : creds.mysql_port,
database : creds.mysql_db,
user : creds.mysql_user,
password : creds.mysql_pass,
multipleStatements : true
});
And when we query the pool we do
pool.query("statement", [inputs], callback);
I have found similar issues online when people are using pool.getConnection
without calling connection.release()
, but we are using pool.query
and cannot release the connection manually.