nodejs socks5-https-client Error: socket hang up

/ 0评 / 0

Solution reference from https://github.com/nodejs/node/issues/37510

The reason is the version compatibility problem, 16 above version cannot run , recommend use socks-proxy-agent

解决方案参考自 https://github.com/nodejs/node/issues/37510

因为这个库用的人不多,所以找起资料来非常困难,耗了两个小时。。最后的答案是,12.16.3可以正常运行,但是16以上的版本是不可以运行的

好吧,换个库,socks-proxy-agent,问题解决 = =

const Agent = require('socks-proxy-agent');
const request = require('request');

request({
    method: 'get',
    url: 'https://api.telegram.org/bot5420777729:AAGh4tXEMD16Sazcs2tRuJm0fZPWSDyWCI4/getUpdates',
    agent: new Agent.SocksProxyAgent({
        hostname: '127.0.0.1',
        port: '7891'
    })
}, (error, response, body) => {
    console.log(error)
    console.log(response)
    console.log(body)
})

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注