2017年6月

request aborted

The error Error: request aborted is somewhat expected, as that error is from Node.js telling us that the TCP socket has closed before we finished reading the request. This does not mean that request is too large, though. The most common causes for this:

  1. User is submitting a form and closes the web browser/browser tab.
  2. User is uploading using a command line tool like cURL and presses Ctrl+C to kill the process.
  3. Some network issue that kills the TCP connection.

可用的解决方案:

使用nginx做反向代理提供服务

nginx

From github

nodejs error: socket hang up

socket hang up 的可能原因有很多,大多是服务器资源不足引起。

检查 ulimit -n (所有的 port process 资源受它限制)
sudo lsof -i|wc -l
检查 memory (内存耗尽也会出错)
free -m

新方案:
使用nginx做反向代理请求nodejs可以有效的减小甚至避免这个问题

location / {
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-NginX-Proxy true;
  proxy_set_header Host $http_host;
  
  proxy_pass http://127.0.0.0:8000; // nodejs server 
  proxy_redirect off;
}

案例:

memory error
ulimit error