When making a large number of requests in node (using version 6.3.0, but this has also occurred on other versions), I get the error getaddrinfo ENOTFOUND.
Researching this problem I found the following github issue for older versions of node: https://github.com/nodejs/node-v0.x-archive/issues/5488
However, I was unable to find a solution within that thread.
That thread did provide the following example code: https://gist.github.com/eelcocramer/5626801
The gist has three files: error-case.js
, fixed-error-case.js
, and success-case.js
However, none of the files work without error for me.
Running error-case.js
produces the following:
...
Request count = 1569
STATUS: 200
Request count = 1570
problem with request: getaddrinfo ENOTFOUND www.google.com www.google.com:80
Last successful request count = 1570
problem with request: getaddrinfo ENOTFOUND www.google.com www.google.com:80
Last successful request count = 1570
...
Yet, when I run fixed-error-case.js
I get the following:
...
Request count = 1562
STATUS: 200
Request count = 1563
problem with request: getaddrinfo ENOTFOUND www.google.com www.google.com:80
Last successful request count = 1563
problem with request: getaddrinfo ENOTFOUND www.google.com www.google.com:80
Last successful request count = 1563
...
And similarly with success-case.js
Request count = 1563
STATUS: 200
Request count = 1564
problem with request: getaddrinfo ENOTFOUND www.google.com www.google.com:80
Last successful request count = 1564
problem with request: getaddrinfo ENOTFOUND www.google.com www.google.com:80
Last successful request count = 1564
^C
But then, even more notably, if I run it again (after >1 min wait), I get the following:
problem with request: getaddrinfo ENOTFOUND www.google.com www.google.com:80
Last successful request count = 0
problem with request: getaddrinfo ENOTFOUND www.google.com www.google.com:80
Last successful request count = 0
problem with request: getaddrinfo ENOTFOUND www.google.com www.google.com:80
Last successful request count = 0
So the error seems to persist through multiple runs, interestingly.
Also, since this example code isn't exactly the code I am actually running, I should also note that I have tried using request-promise
in conjunction with bluebird's map
function with concurrency
so that only so many promises are active at a time, but that has not solved the problem either. (Attempting to run ~300 requests, with concurrency set to 5 still resulted in failure)
Any help/thoughts would be appreciated.
Thanks