use*_*436 6 javascript request node.js getaddrinfo
在节点中发出大量请求时(使用版本6.3.0,但这也发生在其他版本上),我收到错误getaddrinfo ENOTFOUND. 研究此问题我发现以下github问题对于旧版本的节点:https:// github .com/nodejs/node-v0.x-archive/issues/5488
但是,我无法在该线程中找到解决方案.
该线程确实提供了以下示例代码:https://gist.github.com/eelcocramer/5626801
要点有三个文件:error-case.js,fixed-error-case.js,和success-case.js
但是,没有任何文件可以正常工作.
运行error-case.js产生以下内容:
...
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
...
Run Code Online (Sandbox Code Playgroud)
然而,当我跑步时,fixed-error-case.js我得到以下内容:
...
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
...
Run Code Online (Sandbox Code Playgroud)
和...一样 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
Run Code Online (Sandbox Code Playgroud)
但是,更值得注意的是,如果我再次运行它(等待> 1分钟后),我会得到以下结果:
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
Run Code Online (Sandbox Code Playgroud)
因此,有趣的是,错误似乎在多次运行中持续存在.
此外,由于这个示例代码不完全是我实际运行的代码,我还应该注意到我已经尝试request-promise与bluebird's map函数一起使用,concurrency以便一次只有这么多的promises是活动的,但是这还没有解决问题无论是.(尝试运行~300个请求,并发设置为5仍然导致失败)
任何帮助/想法将不胜感激.
谢谢