当我在启动服务器后发送第一个请求时,一切正常。但是在更新页面(重新查询)后,您会收到一个错误:
app.get('/images', function(req, res, next) {
if (connection.state === 'disconnected'){
connection.connect();}
else {
}
var DATABASE='nodejsImage';
var results;
connection.query('use ' + DATABASE);
connection.query('SELECT `id`, `imagename`, `filename`, `speed`, `move` FROM `images` WHERE 1',
function (err, results, fields) {
if (err) return console.log("Error test") //throw err;
else {
console.log('Images list');
console.log('----------------------------------');
for (var i in results) {
var gadget = results[i];
console.log(gadget.id +': '+ gadget.imagename+': '+gadget.speed+': '+gadget.move);
}
res.render('imagelist', { title: 'Imagelist',listImages:results });
}
});
connection.end(); //разобраться с ошибкой позже!!!
});
错误消息:
events.js:165抛出器;//未处理的“错误”事件^
Error: Cannot enqueue Handshake after invoking quit.
at Protocol._validateEnqueue (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\mysql\lib\protocol\Protocol.js:204:16)
at Protocol._enqueue (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\mysql\lib\protocol\Protocol.js:139:13)
at Protocol.handshake (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\mysql\lib\protocol\Protocol.js:52:23)
at Connection.connect (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\mysql\lib\Connection.js:118:18)
at E:\Dropbox\untitled5-upload-3\untitled5\app.js:48:16
at Layer.handle [as handle_request] (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\express\lib\router\layer.js:95:5)
at next (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\express\lib\router\layer.js:95:5)
at E:\Dropbox\untitled5-upload-3\untitled5\node_modules\express\lib\router\index.js:281:22
Emitted 'error' event at:
at Connection._handleProtocolError (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\mysql\lib\Connection.js:425:8)
at Protocol.emit (events.js:180:13)
at Protocol._delegateError (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\mysql\lib\protocol\Protocol.js:392:10)
at Handshake.<anonymous> (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\mysql\lib\protocol\Protocol.js:221:10)
at Handshake.emit (events.js:180:13)
at Handshake.Sequence.end (E:\Dropbox\untitled5-upload-3\untitled5\node_modules\mysql\lib\protocol\sequences\Sequence.js:83:12)
at E:\Dropbox\untitled5-upload-3\untitled5\node_modules\mysql\lib\protocol\Protocol.js:225:14
at process._tickCallback (internal/process/next_tick.js:112:11)
1条答案
按热度按时间hmtdttj41#
这是一个简单的方法来添加通行证项目,以查看。