Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Proxy with https protocol not worked #892

Open
lugin-dev opened this issue Jul 2, 2020 · 2 comments
Open

Question: Proxy with https protocol not worked #892

lugin-dev opened this issue Jul 2, 2020 · 2 comments

Comments

@lugin-dev
Copy link

lugin-dev commented Jul 2, 2020

const HttpsProxyAgent = require('https-proxy-agent')
const fetch = require('node-fetch')

const url = 'https://jsonplaceholder.typicode.com/todos/1'
const proxy = 'https://36.75.245.191:8080'
// const proxy = 'http://36.75.245.191:8080' <= with http worked

const sendReq = async () => {
    try {
        const res = await fetch(url, { agent: new HttpsProxyAgent(proxy) })
        const data = await res.json()
        console.log(data)
    } catch (err) {
        console.log(err)
    }
}

sendReq()

FetchError: request to https://jsonplaceholder.typicode.com/todos/1 failed, reason: Client network
socket disconnected before secure TLS connection was established
at ClientRequest. (C:\Projects...\node_modules\node-fetch\lib\index.js:1455:11)
at ClientRequest.emit (events.js:311:20)
at onerror (C:\Projects...\node_modules\agent-base\dist\src\index.js:114:21)
at callbackError (C:\Projects...\node_modules\agent-base\dist\src\index.js:133:17)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
message: 'request to https://jsonplaceholder.typicode.com/todos/1 failed, reason: Client network
socket disconnected before secure TLS connection was established',
type: 'system',
errno: 'ECONNRESET',
code: 'ECONNRESET'
}

Same on Python worked

import requests
import json

proxies = {
    'https': 'https://36.75.245.191:8080'
}

resp = requests.get('https://jsonplaceholder.typicode.com/todos/1', proxies=proxies)
print(json.loads(resp.text))
@tekwiz
Copy link
Member

tekwiz commented Nov 29, 2020

@lugin-design What happens if you try the request with just the https module? Try this and let me know what happens:

const HttpsProxyAgent = require('https-proxy-agent')
const https = require('https');

const url = 'https://jsonplaceholder.typicode.com/todos/1'
const proxy = 'https://36.75.245.191:8080'
// const proxy = 'http://36.75.245.191:8080' <= with http worked

https.get(url, { agent: new HttpsProxyAgent(proxy) }, res => {
  console.dir(res);
  res.pipe(process.stdout);
}).on('error', e => console.error(e.stack));

@iakoug
Copy link

iakoug commented Sep 18, 2021

Same issue in CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants