Monit and connection reset by peer

1,106 views
Skip to first unread message

Kelvin Chua

unread,
Apr 17, 2015, 10:09:52 AM4/17/15
to nod...@googlegroups.com
so i have monit accessing a test URL on my nodejs server (running under PM2), this happens once a day, causing my nodejs to restart every day

failed
 protocol test [HTTP] at INET[localhost:80/test] via TCP -- HTTP: Error receiving data -- Connection reset by peer


I am using express,
var express = require('express'),
        http = require('http'),
        https = require('https'),
        admin = require('./admin');

web.get('/test', admin.test);

and on admin.js

exports.test = function(req, res) {
        res.send("OK");
}

I don't see any errors on my logs whenever this happens, i have these catches

process.on('uncaughtException', function(err) { c.log("Uncaught Exception",err.stack); });
process.addListener('SIGPIPE', function (err) { c.log("SIGPIPE",err.stack); });


I don't know where the connection reset happens, anyone has any idea how i can isolate the problem?

Jimb Esser

unread,
Apr 20, 2015, 9:47:38 PM4/20/15
to nod...@googlegroups.com
Try removing some variables - I'm unfamiliar with PM2, so I'd try just running your node server directly from a console, and then having monit send it's query (add a minutely query to localhost:81 or something for testing).  If the node process is exiting, it should become apparent why (that being said, I'd hope that PM2 would show similar information in its logs somewhere as well, but having one less moving part should make it easier to isolate the issue).

Just a shot in the dark, but my guess would be that whatever data monit is sending is thought to be malformed http by node's native http parser and that's throwing an exception or something, although in theory your process.on('uncaughtException') is supposed to grab that (though if PM2 is hooking uncaughtException, yours might be being ignored or something).

Hope this helps!
  Jimb Esser
Reply all
Reply to author
Forward
0 new messages