简体   繁体   中英

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

The nodejs server response error message on high load.

Some of the errors are: Http failure response for (api url):0 Unknown Error and cors error. 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

We have 16 GB ram 4vCPUs aws instance

nginx rever proxy to loadbalance between 4 instance of node (created through pm2), ip_hash (as we are using socketio)

while looking through the web some suggestions were " Its cors error ", " it server side error, contact the backend team "

for cors We am using cors package from npm. 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. it may not be the cors error. 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.

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; . Now we get error *2908 socket() failed (24: Too many open files) while connecting to upstream,

Update 4: Adding worker_rlimit_nofile 20000; to the /etc/nginx/nginx.conf seems to fix the error on update 3.

The cors error is emit by the browser, not the server. server just gives browser cors policy response. 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 connect Node.js REST unexpeceed end of stream

java.io.IOException: unexpected end of stream on Connection in android

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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