My node.js app is getting an Unhandled 'error&

2019-08-12 07:00发布

I am running node.js(0.8.20 and 0.9.10) on windows 2012 server. I have ran it absolutely without any problems for weeks. That was without Nginx(1.2.6) in front. With nginx in front configured like this:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
worker_connections  1024;
}


http {
include       mime.types;
default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

upstream dem2 {
    server 127.0.0.1:8080;
}

server {
    listen 80;
    server_name dem2.cz dem2;
    access_log /nginx-1.2.6/logs/dem2.log;
    location / {
        #proxy_pass http://127.0.0.1:8080/;
        proxy_pass http://dem2/;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_redirect off;
    }
}   

server {
    listen 80;
    server_name localhost;

    location / {
        root   html;
        index  index.html index.htm;
    }

}

}

On requests, I randomly get this error in Node.js app:

events.js:69
    throw arguments[1]; // Unhandled 'error' event
                   ^
Error: socket hang up
    at createHangUpError (http.js:1383:15)
    at ServerResponse.OutgoingMessage._writeRaw (http.js:499:26)
    at ServerResponse.OutgoingMessage._send (http.js:466:15)
    at ServerResponse.OutgoingMessage.end (http.js:911:18)
    at SendStream.notModified (C:\dem2cz_node_app\node_modules\express\node_modules\send\lib\send.js:223:7)
    at SendStream.send (C:\dem2cz_node_app\node_modules\express\node_modules\send\lib\send.js:353:17)
    at SendStream.pipe     (C:\dem2cz_node_app\node_modules\express\node_modules\send\lib\send.js:322:10)
    at Object.oncomplete (fs.js:93:15)

Process finished with exit code 1

I suspect I have something wrong configured in Nginx, but I sure as hell don't know what it could be. Could anyone advise please?

I can post the node.js code too if you want, but it is nothing fancy, just 100 line express app for serving AngularJS static files with the option to serve HTML generated in PhantomJS when there is a bot.

1条回答
ら.Afraid
2楼-- · 2019-08-12 08:04

There was a bugfix in 0.8.20 which significantly raised the number of "http hang-up" errors you get. They talk about it in the release notes. As @robertkelp said, it's nothing to worry about, but you should catch error events emitted by the http server to avoid crashing the server.

查看更多
登录 后发表回答