Bri*_*Hsu 5 timeout nginx node.js angularjs connect-timeout
我一直在抓住这个超时问题并希望得到一些帮助.我有一个http请求可能需要2.5分钟才能返回响应.我在Angular中处理超时处理3分钟,NodeJS处理3分钟.我的nginx设置有200秒超时,我的Elastic Load Balancing连接超时设置为4分钟.但是,我一直在2分钟内看到502坏网关nginx 1.4.6(Ubuntu)错误.有没有我错过超时的部分?
我的nginx设置:
server {
listen 80;
server_name;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_pass http://localhost:8060;
proxy_redirect off;
proxy_connect_timeout 200s;
proxy_send_timeout 200s;
proxy_read_timeout 200s;
send_timeout 200s;
}
#Handle protected assets using 'internal' directive documented here: https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/
location /protected {
internal;
expires -1;
}
}
Run Code Online (Sandbox Code Playgroud)
我的NodeJS设置正在使用connect-timeout
var timeout = require('connect-timeout');
app.use(timeout(300000));
Run Code Online (Sandbox Code Playgroud)
Mar*_*mek 10
我今天刚遇到这个,可能找到了答案 - 节点http模块中有 120 秒的硬编码超时。我必须在给定的请求处理程序中设置套接字超时,如下所示:
yourHandler(req, res) {
req.socket.setTimeout(3600e3); // 1 hour
// ... do the real work
res.json(...);
}
Run Code Online (Sandbox Code Playgroud)
您还可以将此限制设置0为禁用此超时。
https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback
最初在这里找到答案:https : //forum.nginx.org/read.php?2,214230,214239#msg-214239
| 归档时间: |
|
| 查看次数: |
3483 次 |
| 最近记录: |