Nodejs Error: getaddrinfo ENOTFOUND & EADDRINFO

I use the Request module to retrieve html pages, it works fine, but after a while I get ENOTFOUND and EADDRINFO on some requests. After browsing the Internet, I found some similar problems ( # 699 , # 5488 , # 697 ), and I understand that I probably do not consume some (or all?) Of the answers and that at some point the application reaches the maximum pool size sockets.

I'm not quite sure about this, but I'm thinking of increasing globalAgent.maxSockets (to 100?) And always consuming the answer by calling response.resume() at the start of the request callback. Does that make sense? Or am I out of the way?

I looked through the Node code to understand what resume() does, but I'm not sure I found the right function ( # L698 ).

Thanks for your help.

+5
source share
1 answer

To the proposal for kanaka, I answer my question with the solution I found:

I did what I said, I will try, and this solved the problem (not quite sure why). Therefore, before initializing the server, I set http.globalAgent.maxSockets = 100 and https.globalAgent.maxSockets = 100 , and every time I use the request module, I add it to the callback: if (response) { response.resume(); } if (response) { response.resume(); }

Maybe this will help someone else :)

0
source

Source: https://habr.com/ru/post/1201892/


All Articles