我在Node.js 6.7.0中使用mysql从数据库中获取数据
connection.query('SELECT * FROM table', function(err, results){
if(err){
console.log('Error while performing the database query:', err);
return;
}else{
console.log('Query results:', results);
}
});
当我收到错误时,我正常打开页面(之前有效):
执行数据库查询时出错:错误:握手不活动 超时
服务器没有停止运行,我刷新了页面,一切正常......
之前从未发生过,这是什么意思?
这是我在日志中收到的完整错误:
Error while performing the database query: { Error: Handshake inactivity timeout
at Handshake.<anonymous> (/Users/johndoe/myproject/node_modules/mysql/lib/protocol/Protocol.js:160:17)
at emitNone (events.js:86:13)
at Handshake.emit (events.js:185:7)
at Handshake._onTimeout (/Users/johndoe/myproject/node_modules/mysql/lib/protocol/sequences/Sequence.js:127:8)
at tryOnTimeout (timers.js:232:11)
at Timer.listOnTimeout (timers.js:202:5)
--------------------
at Protocol._enqueue (/Users/johndoe/myproject/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Protocol.handshake (/Users/johndoe/myproject/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at PoolConnection.connect (/Users/johndoe/myproject/node_modules/mysql/lib/Connection.js:136:18)
at Pool.getConnection (/Users/johndoe/myproject/node_modules/mysql/lib/Pool.js:48:16)
at Pool.query (/Users/johndoe/myproject/node_modules/mysql/lib/Pool.js:200:8)
at /Users/johndoe/myproject/myscript.js:92:13
at Layer.handle [as handle_request] (/Users/johndoe/myproject/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/johndoe/myproject/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/johndoe/myproject/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/johndoe/myproject/node_modules/express/lib/router/layer.js:95:5)
code: 'PROTOCOL_SEQUENCE_TIMEOUT',
fatal: true,
timeout: 10000 }