我正在运行node.js
服务器,但我也在运行-但是很糟糕,直接导致了一个真正的大错误:
恰好关闭连接,崩溃并产生以下错误消息:
{ Error: Connection lost: The server closed the connection.
at Protocol.end (/home/node/app/node_modules/mysql/lib/protocol/Protocol.js:112:13)
at Socket.<anonymous> (/home/node/app/node_modules/mysql/lib/Connection.js:97:28)
at Socket.<anonymous> (/home/node/app/node_modules/mysql/lib/Connection.js:502:10)
at Socket.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1092:12)
at process._tickCallback (internal/process/next_tick.js:63:19) fatal: true, code: 'PROTOCOL_CONNECTION_LOST' }
我知道此错误来自mysql
,因此我花了几个小时来寻找解决方案。但是对我来说,它们似乎都不起作用。
PROTOCOL_CONNECTION_LOST
con.on('error', function(err) {
mysqlConnection();
})
con.on('close', function(err) {
mysqlConnection();
})
function mysqlConnection() {
con = mysql.createConnection({
host: "xy",
user: "xy",
password: "xy",
database: "xy",
});
con.connect(function(error) {})
}
(3,600,000)
内发送查询setInterval(function () {
con.query("SELECT * FROM xy", [], (err,result,fields)=>{})
}, 3600000); // every hour
con.destroy();
似乎没有一个修复程序对我有用。因此,希望我可以对我发现的outdated questions和answers进行一些更新。