SSL版本号错误

问题描述 投票:0回答:1

我正在尝试使用代理运行我的代码node.js来收集网站https上的数据。但是当我通过网络发出请求时,我收到消息错误:

cause: Error: write EPROTO 085C0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:355

我想了解为什么。

代码:

const axios = require('axios');
const tunnel = require('tunnel');
const https = require('https');


async function sss() {

  try {
    const responsePromise = await axios.request({
      url: 'https://api.ipify.org/?format=json',
      method: 'get',
      headers: {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'
      },
      port: 443,
      proxy: {
        host: '117.160.250.133',
        port: 8899
      },
    });

    console.log(await responsePromise);
  } catch (ex) {
    console.log(ex);
  }
}
sss();

我知道,如果我在 http 上发出请求并将端口更改为 80 我可以,但我需要请求 https。关于代理,我正在使用 PubProxy

谢谢你帮助我。

node.js ssl axios proxy
1个回答
0
投票

指定代理不支持代理https流量:

$ https_proxy=http://117.160.250.133:8899 curl -v 'https://api.ipify.org/?format=json'
* Uses proxy env variable https_proxy == 'http://117.160.250.133:8899'
*   Trying 117.160.250.133:8899...
* Connected to 117.160.250.133 (117.160.250.133) port 8899 (#0)
* allocate connect buffer
* Establish HTTP proxy tunnel to api.ipify.org:443
> CONNECT api.ipify.org:443 HTTP/1.1
> Host: api.ipify.org:443
> User-Agent: curl/7.87.0
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 400 Bad Request
< Server: openresty
< Date: Mon, 11 Mar 2024 22:35:23 GMT
< Content-Type: text/html
< Content-Length: 154
< Connection: close

修复:使用不同的代理并确保它首先支持代理 https。

© www.soinside.com 2019 - 2024. All rights reserved.