1

I wrote http server in node.js, which is a like reverse-proxy for Amazon S3, and deployed it in production environment with Node's Cluster module, nodejitsu/forever and Nginx. It worked very good but one day (today) it stopped responding. I checked node's console.log() outputs and processes but I found nothing strange.

Gist of my code is like:

http.createServer(function(webReq, webRes) {
  http.get(s3Options, function(s3Res) {
    if (s3Res.statusCode == 200) {
      s3Res.on('end', function() {
        webRes.end('Found data on S3');
      });
    } else {
      webRes.end('No data on S3'); 
    }
  }).on('error', function(e) {
    console.log('problem with s3Req: ' + e.message);
  });
}).listen(1337);

Node processes are all alive (2 child workers) without forever's restarting:

# ps x | grep node
31436 ?  Ss  3:43 node /usr/bin/forever -l LOG -o OUT -e ERR -a start server.js
31437 ?  Sl  0:10 node /root/server.js
31440 ?  Sl  1:17 /usr/bin/nodejs /root/server.js
31441 ?  Sl  1:17 /usr/bin/nodejs /root/server.js

Then I doubted too-many-connection stuffs and did "lsof -p PID | wc -l" but the counts were all in good conditions - only dozens.

My node.js experience is only a week or so. Did I miss something important?

5
  • My concern is not the reason why my node server doesn't respond but why it doesn't output any errors.
    – chikaram
    Jun 20, 2012 at 14:09
  • Tested your code locally (with a request to google.com, since I don't have the contents of s3Options) and it works as expected (gives Found data on S3). The issue appears to be specific to your actual s3Options request.
    – lanzz
    Jun 20, 2012 at 14:19
  • Thank you, lanzz. var s3Options = { host: '*****.s3.amazonaws.com', port: 80, path: webReq.url, method: 'GET', }; But this has worked well until today. Should I add timeout param?
    – chikaram
    Jun 20, 2012 at 14:28
  • So you are logging other messages? When you say the server isn't responding, do you mean a request to 1337 times out? Jun 20, 2012 at 20:35
  • Matthew, yes, I was logging other messages and every things were ok until the server stopped. When opening xxx:1337, my browser kept loading and didn't stop. Then I restarted forever it started to work well again. But I'm still afraid the same thing will happen again.
    – chikaram
    Jun 22, 2012 at 1:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.