When doing many http.get-requests to localhost (Apache) after 28233 requests I get EADDRNOTAVAIL
.
When broken:
I have found the solution by overwriting the default global agent. One possibility is to set maxSockets:1
:
var http = require( "http"),
agent = new http.Agent( {maxSockets: 1} ); // <-- this is new
function httpRequest( callback ) {
var options = {
host: 'localhost',
port: 80,
path: '',
agent: agent // <-- and this is new
},
...
With this correction the example above works. But I still had the EADDRNOTAVAIL issue within my production code, so setting the agent
to false
did it finally:
var http = require( "http");
function httpRequest( callback ) {
var options = {
host: 'localhost',
port: 80,
path: '',
agent: false // <-- here
},
...
I have posted this issue also on GitHub.
MacOS solution , or at least what worked for me
and sending the request to mac.local