Search code examples
javascriptnode.jshttpnode-red

NodeRED - Connect ECONNREFUSED with multiples HTTP requests


We are encountering an issue when we are doing a lot of requests using HTTP Request on our NodeJS API server using NodeRED.

By the way, we also tested this using our WWW Request node which his implemented on the Request library. The result is the same :(

Here is the error stacktrace:

error:
  { message: 'Error: connect ECONNREFUSED 163.113.172.80:1337',
    source:
     { id: '5d2aa78c.a2d558',
       type: 'http-request',
       name: undefined,
       count: 1 },
    stack: 'Error: connect ECONNREFUSED 163.113.172.80:1337\n    at
    Object.exports._errnoException (util.js:856:11)\n    at
    exports._exceptionWithHostPort (util.js:879:20)\n    at
    TCPConnectWrap.afterConnect [as oncomplete] (net.js:1062:14)' } }

Of course, we tested our API server using Apache Benchmark (ab CLI) with success (no failure) and an API Rate of 500 req/s.

Technical information :

  • Node-RED version: v0.14.5
  • Node.js  version: v5.5.0
  • Windows_NT 6.1.7601 x64 LE
  • Processor: Intel Xeon CPU E5-630 v3 3.70Ghz 8 Cores
  • Memory: 64 Gb

Any idea ?


Solution

  • We've found an workaround by setting the max sockets value like this :

    http.globalAgent.maxSockets = 100;
    https.globalAgent.maxSockets = 100; 
    

    By default, the HTTP(S) global agent max socket value seems to be infinite...