0

错误:RequestError:错误:getaddrinfo ENOTFOUND socks5://1.1.1.1:1000

使用过的 NodeJS 模块:

请求承诺袜子代理代理

所以,我确信我的代码是正确的,并且遵循了很多例子,但是当它运行时,它会输出这个错误。我能想到的是 request-promise 尝试连接到 socks5 主机而不是指定的请求 URL。

代码如下,

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;

更新:

通过如下更改连接对象上的键,我能够产生不同的错误,

const connection_info = {
//host: core_proxy,
protocol:"socks5:",
host:req.body.ip,
port:req.body.port,
username: req.body.username,
password: req.body.password

}

新错误是 错误:代理连接超时

更新:

我已将超时设置为 20000,但它仍然给出相同的错误。

我想我可能不得不尝试使用另一个代理。

更新:

尝试使用另一个代理,同样的错误。

我想不出这里还缺少什么。

4

1 回答 1

1

我能够通过使用另一个名为 socks5-https-client 的 socks5 库来解决这个问题。而且,我仍然不知道其他图书馆的确切问题是什么。

我把它留给专家来解决。

于 2020-03-01T15:38:20.607 回答