【问题标题】:Request-Promise Library Error when using socks5:- RequestError: Error: getaddrinfo ENOTFOUND使用 socks5 时的请求承诺库错误:- RequestError:错误:getaddrinfo ENOTFOUND
【发布时间】:2020-02-29 23:07:18
【问题描述】:

错误: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,但它仍然给出相同的错误。

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

更新:

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

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

【问题讨论】:

    标签: node.js


    【解决方案1】:

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

    我把它留给专家来解决。

    【讨论】:

      猜你喜欢
      • 2022-11-04
      • 2019-01-06
      • 1970-01-01
      • 2018-04-02
      • 2021-05-10
      • 2019-09-19
      • 2017-10-16
      • 2021-08-10
      • 2014-10-20
      相关资源
      最近更新 更多