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

On Friday, April 17, 2015 at 7:09:52 AM UTC-7, Kelvin Chua wrote:
>
> 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?
>
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/86f46fdb-df09-483b-b314-1175980b4646%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to