requests proxy 不支持https吗?

这样写代码是没错的,代理的IP是有效的,支持HTTP,也支持HTTPS

const request = require('request');

let proxyUrl = 'http://119.117.29.15:8943';
request.get({
    url  : 'https://pv.sohu.com/cityjson?ie=utf-8',
    proxy: proxyUrl
}, (err, rep, body) => {
    console.log(err);
    console.log(body);
});

但是如果我将请求的proxy修改成https,就不行了,请问怎么解决

let proxyUrl = 'https://119.117.29.15:8943';

报错如下:

{ Error: tunneling socket could not be established, cause=Client network socket disconnected before secure TLS connection was established
    at ClientRequest.onError (/Library/WebServer/Documents/html/info.zhaoyaojing.client_node/node_modules/_tunnel-agent@0.6.0@tunnel-agent/index.js:177:17)
    at Object.onceWrapper (events.js:273:13)
    at ClientRequest.emit (events.js:182:13)
    at TLSSocket.socketErrorListener (_http_client.js:375:9)
    at TLSSocket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19) code: 'ECONNRESET' }
阅读 10.2k
1 个回答

HTTPS需要证书来证明域名,IP是不会有证书的。所以你的代理使用https是无法正常工作的

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏