简体   繁体   English

Node.js 有时服务器响应错误(高负载)

[英]Node.js Server Response Error sometime (on High load)

The nodejs server response error message on high load.高负载时的 nodejs 服务器响应错误消息。

Some of the errors are: Http failure response for (api url):0 Unknown Error and cors error.一些错误是: Http failure response for (api url):0 Unknown Errorcors错误。 On the browser console.在浏览器控制台上。

On Android side the error is unexpected end of stream on Connection {api url:80, proxy=Direct hostaddress=apiurl/serverip:80 cipherSuite=none protocol=http/1.1在 Android 端,错误是unexpected end of stream on Connection {api url:80, proxy=Direct hostaddress=apiurl/serverip:80 cipherSuite=none protocol=http/1.1

We have 16 GB ram 4vCPUs aws instance我们有 16 GB ram 4vCPUs aws 实例

nginx rever proxy to loadbalance between 4 instance of node (created through pm2), ip_hash (as we are using socketio) nginx 反向代理到节点的 4 个实例(通过 pm2 创建)、ip_hash(因为我们使用的是 socketio)之间的负载平衡

while looking through the web some suggestions were " Its cors error ", " it server side error, contact the backend team "在查看 web 时,一些建议是“ Its cors error ”,“ it server side error, contact the backend team

for cors We am using cors package from npm.对于cors我们使用 cors package 来自 ZBB30E85411B56DF41296726AB445DCF8。 app.use(cors()) . app.use(cors()) I am looking for the server side fixation.我正在寻找服务器端的固定。 we are using express.我们正在使用快递。

since the website and app works perfectly while its working, and we get cors error during the problem.由于网站和应用程序在其工作时完美运行,并且在问题期间我们收到 cors 错误。 it may not be the cors error.它可能不是 cors 错误。 during the high load, we get the error instantly, not time out error.在高负载期间,我们会立即收到错误,而不是超时错误。

We could not figure out the issue.我们无法弄清楚这个问题。 any suggestions?有什么建议么?

Update: Since there are voting going on to close this, I may not get the answer, but here are some errors, Please note that the app and website (angular) works fine but got these error during pick hours, I expect timeout or node to stop, but not these errors so, thought something is wrong.更新:由于正在进行投票以关闭此问题,我可能无法得到答案,但这里有一些错误,请注意应用程序和网站(角度)工作正常,但在挑选时间出现这些错误,我预计超时或节点停下来,但不是这些错误如此,以为有问题。

控制台上的错误 - Angular

安卓上的错误

Update2: While looking though the nginx error log, we get this error. Update2:在查看 nginx 错误日志时,我们收到此错误。

2021/03/09 17:10:25 [alert] 1058#1058: *2946806 768 worker_connections are not enough while connecting to upstream, client: 120.xx.xxx.114, server: api.mydomain.com, request: "GET /Image-1611905660330.jpg HTTP/1.1", upstream: "http://127.0.0.1:8000/Image-1611905660330.jpg", host: "api.mydomain.com"

Update 3: Looking for the above error, found suggestion that, we need to increase worker_connections , so we update it on /etc/nginx/nginx.conf;更新3:查找上面的错误,发现提示需要增加worker_connections ,所以在/etc/nginx/nginx.conf; . . Now we get error *2908 socket() failed (24: Too many open files) while connecting to upstream,现在我们*2908 socket() failed (24: Too many open files) while connecting to upstream,

Update 4: Adding worker_rlimit_nofile 20000;更新 4:添加worker_rlimit_nofile 20000; to the /etc/nginx/nginx.conf seems to fix the error on update 3./etc/nginx/nginx.conf似乎修复了更新 3 上的错误。

The cors error is emit by the browser, not the server. cors 错误是由浏览器而不是服务器发出的。 server just gives browser cors policy response.服务器只是给浏览器 cors 策略响应。 Whether it should be treated as error or not is decided by the browser itself.是否应视为错误由浏览器本身决定。

I'm not android developer, but i think some of your problem is made by misused request from android client, not server.我不是 android 开发人员,但我认为您的一些问题是由来自 android 客户端而不是服务器的滥用请求造成的。

Android connect Node.js REST unexpeceed end of stream Android 连接 Node.js REST 意外结束 ZF7B44CFAFD5C52223D5498196CA8

java.io.IOException: unexpected end of stream on Connection in android java.io.IOException: stream on Connection in ZC31B32364CE19CA88FCD5C1 意外结束

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM