如何在node.js https / request Client中使用https代理?

时间:2015-12-04 00:43:04

标签: node.js https proxy

我需要通过Intranet代理将我的客户端HTTPS请求发送到服务器。 我同时使用https和request + global-tunnel,两种解决方案似乎都不起作用 使用' http'的相似代码作品。我错过了其他设置吗?

代码失败并显示错误:

REQUEST:
problem with request: tunneling socket could not be established, cause=socket hang up

HTTPS:
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: socket hang up
    at SecurePair.error (tls.js:1011:23)
    at EncryptedStream.CryptoStream._done (tls.js:703:22)
    at CleartextStream.read [as _read] (tls.js:499:24)

代码是简单的https测试。

var http = require("https");

var options = {
  host: "proxy.myplace.com",
  port: 912,
  path: "https://www.google.com",
  headers: {
    Host: "www.google.com"
  }
};

http.get(options, function(res) {
  console.log(res);
  res.pipe(process.stdout);
});

0 个答案:

没有答案