0

I'm doing a stress test to my nodejs app, the test basically send a bulk of requests concurrently, sometimes I got this annoying error:

{ RequestError: Error: connect ECONNREFUSED 127.0.0.1:1234
at new RequestError (/mnt/c/Users/rawhi/Desktop/myCode/backend/api/node_modules/request-promise-core/lib/errors.js:14:15)
at Request.plumbing.callback (/mnt/c/Users/rawhi/Desktop/myCode/backend/api/node_modules/request-promise-core/lib/plumbing.js:87:29)
at Request.RP$callback [as _callback] (/mnt/c/Users/rawhi/Desktop/myCode/backend/api/node_modules/request-promise-core/lib/plumbing.js:46:31)
at self.callback (/mnt/c/Users/rawhi/Desktop/myCode/backend/api/node_modules/request/request.js:185:22)
at Request.emit (events.js:198:13)
at Request.onRequestError (/mnt/c/Users/rawhi/Desktop/myCode/backend/api/node_modules/request/request.js:881:8)
at ClientRequest.emit (events.js:198:13)
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:198:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: 'RequestError',
message: 'Error: connect ECONNREFUSED 127.0.0.1:1234',
cause:
{ Error: connect ECONNREFUSED 127.0.0.1:1234
   at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
 errno: 'ECONNREFUSED',
 code: 'ECONNREFUSED',
 syscall: 'connect',
 address: '127.0.0.1',
 port: 1234 }

So the test keeps returning this error for "almost" all the requests, but I still can send requests via postman without any problem. Can anyone explain me what is the problem here ? and how it can be solved ? like using a queue a proxy or anything else useful ?
Thanks in advance

Rawhi
  • 6,155
  • 8
  • 36
  • 57
  • 1
    You could be exhausting the accept listen queue. Normally an app will limit how many "pending" connections it will accept, and this is often ~128-256. – tadman Apr 24 '20 at 20:35
  • Thank you, so is there anything that could be done, apart from running more instances ? – Rawhi Apr 24 '20 at 20:38
  • You can increase that queue if necessary. You haven't shown your server code, but the key is where you call [`listen`](https://nodejs.org/docs/latest/api/net.html#net_server_listen). The `backlog` parameter can usually be adjusted, and that's how many "unconfirmed" connections it can queue up. – tadman Apr 24 '20 at 20:46

0 Answers0