Does requests proxy not support https?

it is correct to write the code in this way. The IP of the agent is valid, and HTTP, is supported as well as 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);
});

but it won"t work if I change the requested proxy to https,. How to solve this problem

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

the error is as follows:

{ 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" }
Mar.21,2021

HTTPS requires a certificate to prove the domain name, and IP will not have a certificate. So your agent will not work properly with https

Menu