Debugging fuzzy exceptions (ECONNRESET) in a node cluster

In my node.js application that uses the cluster module, I periodically see errors like this:

events.js:71 throw er; // Unhandled 'error' event ^ Error: read ECONNRESET at errnoException (net.js:863:11) at TCP.onread (net.js:524:19) 

This crashes my entire application, and so far the only way I could handle it is by binding process.on('uncaughtException') . I would like to find out the reason, but the above stack trace is pretty useless.

Is there any way to find out what causes these exceptions?

I should notice that I see them only in the cluster, and not among the workers, which makes me suspect that they have something to do with how the cluster modules do their magic in distributing connections with workers.

+7
source share
2 answers

This answer was useful: stack overflow

Basically, I installed longjohn and then was able to get a full trace of the asynchronous computing stack to find out the reason (rabbit. Js in my case).

+1
source

Express seems to be enabled by default. To close the connection after the response, you can add res.set("Connection", "close");

Alternatively, you can add middleware in your application to close the connection after each answer:

  app.use(function(req, res, next) { res.set("Connection", "close"); next(); }); 
0
source

All Articles