I wrote a server application in Node.js.
When I do lsof -p 10893
(10893 is the pid of my Node.js application), I get this:
node 10893 root 19u IPv4 (num) 0t0 TCP ip-X.X.X.X->ip-X-X-X.X:45403 (ESTABLISHED)
node 10893 root 19u IPv4 (num) 0t0 TCP ip-X.X.X.X->ip-X-X-X.X:58416(ESTABLISHED)
This connections are hold and never closed, just when I restart my application.
I have the following code in node.js, which as I understand, should handle this issue:
app.use(function(err, req, res, next) {
res.setTimeout(120000);
res.status(500).send('Unexpected error');
});
But these connection are still appears, even after 120000 ms.
How can I fix it?