简体   繁体   中英

Node-mysql pool.query gets disconnected after 10 minute query

I'm using nodejs with node-mysql to connect to a mysql database. I'm using pool.query to call a stored procedure in the database. This particular one takes quite a while to run. I receive this error

Error: Connection lost: The server closed the connection.

After exactly 10 minutes of waiting for the query to complete. The server is hanging up on me (because the connection has been idle for too long?), but I can't find any mysql variable that would be causing a disconnect after 10 minutes. I'm sure I've just got something misconfigured, but can't track down what that might be.

setInterval(function () {
    db.query('SELECT 1');
}, 300000);

excute the query for every 5 minutes keeps the connection live so it might solve your problem

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