socks5-https-client
socks5-https-client copied to clipboard
Error: getaddrinfo EMFILE localhost:9050
I have a request inside loop. After starting my program it gives this error:
Error: getaddrinfo EMFILE localhost:9050
Is there any option for close socket after request?
Hi @alparslanahmed, I'm not sure I understand. Have you tried calling #close() on the request object?
Hi @mattcg, here its the code above. I am executing this method every 500ms.
static events() {
const userAgentString = userAgentGenerator();
request({
url: listUrl,
agentClass: Agent,
agentOptions: {
socksHost: 'localhost',
socksPort: 9050
},
headers: {
'User-Agent': userAgentString
},
forever: true,
pool: { maxSockets: Infinity }
}, function (err, res) {
if (err) {
console.error('Error when requesting events list: ', err);
} else if (!res) {
console.log('Null response when requesting events list: ', res);
} else {
Service.parseEvents(res.body);
}
});
}
And this is console output for every request:
Error when requesting events list: { Error: getaddrinfo EMFILE localhost:9050
at Object.exports._errnoException (util.js:1036:11)
at errnoException (dns.js:33:15)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
code: 'EMFILE',
errno: 'EMFILE',
syscall: 'getaddrinfo',
hostname: 'localhost',
host: 'localhost',
port: 9050 }
@alparslanahmed the error means that your system is denying Node.js permission to open more sockets. It could be that in your loop you aren't waiting for the request to complete before the next iteration and are therefore flooding your system with connections.