Reputation:
Error: RequestError: Error: getaddrinfo ENOTFOUND socks5://1.1.1.1:1000
Used NodeJS Modules:
request-promise socks-proxy-agent
So, I'm sure that my code is right and followed lot of examples but when it runs, it output this error. What I can think of is that request-promise trying connect to socks5 host instead of the specified request URL.
Code is below,
async function main() {
const proxy = "socks5://"+req.body.ip+":"+req.body.port
// Connection Info
const connection_info = {
host: proxy,
userId: req.body.username,
password: req.body.password
}
//Initialize Connection + Start Agent
const agent = new SocksProxyAgent(connection_info);
//Request using request-promise library
var options = {
method: 'POST',
uri: 'https://endpoint.goes.here',
agent: agent,
headers: {
'User-Agent': req.body.useragent
},
body: {
id: "1"
},
json: true
}
return await rp(options)
}
let response = main(); // Call Async Function, Save Response Object
var headers = response.headers;
var body = response.body;
UPDATE:
I was able to produce different error by changing keys on connection object as follows,
const connection_info = {
//host: core_proxy,
protocol:"socks5:",
host:req.body.ip,
port:req.body.port,
username: req.body.username,
password: req.body.password
}
New error is Error: Proxy connection timed out
UPDATE:
I have set timeout to 20000, but it still gives same error.
I guess I might have to try with another proxy.
UPDATE:
Tried with another proxy, same error.
I can't think of what else is missing here.
Upvotes: 0
Views: 1763
Reputation:
I was able to solve this by using an another socks5 library called socks5-https-client. And, I still don't know what's the exact issue with other library.
I leave it to experts to figure-out.
Upvotes: 1