I am using nodemon npm package for automatically restarting the node application when file changes in the directory are detected. Server is created by using express and http npm package. The problem is when server is idle for few minutes it throws error Error: read ECONNRESET actual error is as follows:
events.js:167
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:111:27)
Emitted 'error' event at:
at Connection._handleProtocolError (/home/abc/node_modules/mysql/lib/Connection.js:425:8)
at Protocol.emit (events.js:182:13)
at Protocol._delegateError (/home/abc/node_modules/mysql/lib/protocol/Protocol.js:390:10)
at Protocol.handleNetworkError (/home/abc/node_modules/mysql/lib/protocol/Protocol.js:363:10)
at Connection._handleNetworkError (/home/abc/node_modules/mysql/lib/Connection.js:420:18)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
I have tried to catch the error but this does not solve my problem.
process.on('uncaughtException', function(err) {
console.log("uncaughtException called: \n", err);
})
The server is created by using express and http:
express = require('express');
app = express();
http = require('http');
var httpServer = http.createServer(app);
httpServer.listen(3000, function(req, res) {
console.log('Server running at port 3000);
});
I expect to prevent the server from ECONNRESET error occurrence What's the solution?