Connection closed by server

156 views
Skip to first unread message

Federico Razzoli

unread,
Mar 14, 2016, 5:13:54 AM3/14/16
to node-mysql
Hello.

My Node application always exits with the error below. It seems to be triggered by the net_wait_timeout setting, in MySQL.
1) Any hints about what causes this error?
2) What is the best way to handle the error?

The error is this:

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: Connection lost: The server closed the connection.
    at Protocol.end (/home/federico/mobile-sync-backend/node_modules/mysql/lib/protocol/Protocol.js:109:13)
    at Socket.<anonymous> (/home/federico/mobile-sync-backend/node_modules/mysql/lib/Connection.js:102:28)
    at emitNone (events.js:72:20)
    at Socket.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at doNTCallback2 (node.js:441:9)
    at process._tickCallback (node.js:355:17)

Bye
Federico

Christopher Newhouse

unread,
May 29, 2016, 11:20:37 AM5/29/16
to node-mysql
Hi Frederico,

From all the things I've read about problems like this, the suggested solution is:

- Use Connection Pools, even if you only set the 'connectionLimit' option to 1.

Various parts of the documentation and responses from Doug Wilson to similar issues all point to using Connection Pool as the solution.  They apparently will handle re-connecting upon disconnect for you behind the scenes:

Hope this helps,
  Chris
Reply all
Reply to author
Forward
0 new messages