几个小时后,Node-mysql池断开连接

时间:2015-02-12 22:49:03

标签: mysql node.js express node-mysql

运行我的快速节点应用程序几个小时后,服务器失去了与mysql服务器的连接。我正在使用连接池,所以它不应该断开连接。以下是我初始化池的方法:

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
});

与我的mysql服务器交谈:

pool.query("statement", [inputs], callback);

服务器是否崩溃且池无法重新连接?即使使用connection.release(),我还需要connection.query吗?服务器报告的错误是:

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)

0 个答案:

没有答案