angularjs – 在Node应用程序的NGINX 502坏网关中,Http请求超时2
发布时间:2020-12-17 10:23:25 所属栏目:安全 来源:网络整理
导读:我一直在抓住这个超时问题并希望得到一些帮助.我有一个http请求可能需要2.5分钟才能返回响应.我在Angular中处理超时处理3分钟,NodeJS处理3分钟.我的nginx设置有200秒超时,我的Elastic Load Balancing连接超时设置为4分钟.但是,我一直在2分钟内看到502坏网关n
我一直在抓住这个超时问题并希望得到一些帮助.我有一个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; } } 我的NodeJS设置正在使用connect-timeout var timeout = require('connect-timeout'); app.use(timeout(300000));
我今天刚刚遇到这个问题,并且可能找到了答案 – 节点的http模块中有120秒的硬编码超时.我不得不在给定的请求处理程序中设置socket超时,如下所示:
yourHandler(req,res) { req.socket.setTimeout(3600e3); // 1 hour // ... do the real work res.json(...); } 您也可以将此限制设置为0以禁用此超时. https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback 最初在这里找到答案:https://forum.nginx.org/read.php?2,214239#msg-214239 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 报错:Couldn't register with the bootstrap server
- CXF发布webservice
- 分享bootstarp3.0.2响应式模板-第三弹[Metronic_Admin]
- 《数据结构》实验一:VC编程环境灵活应用
- angularjs – 哪个使用,AngularUI Bootstrap或AngularStrap
- 算法 – Scala与Java性能
- 将Scala数组转换为Java数组的最快方法
- angularjs – 不显示在$scope中的表单元素
- vim – 如何在创建必要的行时粘贴块以仅为块提供空间?
- Scala:类中的字段和构造函数中的参数之间的真正区别是什么