0

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.

error on console - Angular

error on android

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.

Sagar Devkota
  • 1,295
  • 3
  • 12
  • 25

1 Answers1

0

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

Bad Dobby
  • 811
  • 2
  • 8
  • 22
  • The website works perfectly fine (no cors error) but during certain period of time, (I assume we get high request in this period) the console show that error. error is: message: "Http failed response for http://the url: 0 Unknown Error" name: "HttpErrorResponse" ok: false status: 0 statusText: "Unknown Error" – Sagar Devkota Mar 08 '21 at 16:38
  • @SagarDevkota It doesn't make sense. Technically, a single core nodejs app can bear more than 1000 concurrent request at once. And, you can get error message that you can explicitly notice when you use nodejs server over max performance. – Bad Dobby Mar 08 '21 at 17:04
  • @SagarDevkota https://stackoverflow.com/questions/56962381/how-to-overcome-nodejs-heap-memory-error/56962449 this is some kind of errors that you can get when you use nodejs out of max performance. In this kind of situation, the server stops instantly and you get error message from nodejs core – Bad Dobby Mar 08 '21 at 17:18
  • Thanks, Bad Dobby, Ya it does not make sense, I tired asking with some friends on my circle for this error, All response were like, it should not be like that. So I tried here. I don't know whether to look on node or db (mongo) or nginx or frontend. It works fine till 4pm (rough), then started getting these error, it works expectedly after 7 - 8 pm till next days. Its been similar for 2 days. :( Any way Thanks! Good day :) – Sagar Devkota Mar 08 '21 at 17:49