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

httpsAgent does not work in combination with an HTTP-proxy. #1981

Closed
Borewit opened this issue Jan 26, 2019 · 8 comments
Closed

httpsAgent does not work in combination with an HTTP-proxy. #1981

Borewit opened this issue Jan 26, 2019 · 8 comments

Comments

@Borewit
Copy link

Borewit commented Jan 26, 2019

Description

I try to setup HTTPS-session using Axios which works fine through Fiddler.
This fails by the way on the current stable release v0.18.0, I guess this is issue #925, fixed in #959.

As soon as I remove Fiddle, it no longer works. I suspect that it is, because the connection is pooled by Fiddler. So in order to make it work without the Fiddler proxy, I inject httpsAgent to keep the connection alive e.g.:

import * as http from 'https';
import * as https from 'https';

const Fiddler = {
  host: '127.0.0.1',
  port: 8888
};

this.axios = Axios.create({
   proxy: Fiddler
   httpAgent: new http.Agent({keepAlive: true}),
   httpsAgent: new https.Agent({keepAlive: true, rejectUnauthorized: false})

I can't get it work with the https-agent assigned, not with a proxy:

Stacktrace:

TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"
    at new ClientRequest (_http_client.js:118:11)
    at Object.request (http.js:41:10)
    at RedirectableRequest._performRequest (node_modules\follow-redirects\index.js:186:24)
    at new RedirectableRequest (node_modules\follow-redirects\index.js:69:8)
    at Object.wrappedProtocol.request (node_modules\follow-redirects\index.js:363:14)
    at dispatchHttpRequest (node_modules\axios\lib\adapters\http.js:180:25)
    at new Promise (<anonymous>)
    at httpAdapter (node_modules\axios\lib\adapters\http.js:20:10)
    at dispatchRequest (node_modules\axios\lib\core\dispatchRequest.js:59:10)

Not without a proxy.

Context

  • axios version: e.g.: (v0.19.0-beta.1)[https://github.com/axios/axios/releases/tag/v0.19.0-beta.1]
  • Environment: e.g.: node v10.13.0, Windows 10

Related issues

@jasonswearingen
Copy link

I got here by searching for a fix on https proxy failures (EPROTO error)

I'm not sure if it's related, but but i know there are/were bugs with setting your own httpsAgent too (to do things like setting keepalive)

@JitixPhotobox
Copy link
Contributor

I have opened a PR to fix this issue : #2426

@JitixPhotobox
Copy link
Contributor

The PR has been merged. Waiting for a new release.

@elegisandi
Copy link

waiting for the new release :)

@arpitjain-in
Copy link

Is this issue resolved and available in latest release? Please share some update on this.

@alilland
Copy link

same :(

@yasuf
Copy link
Collaborator

yasuf commented Nov 27, 2019

see #2502, this will be fixed once that version is out, thank you for your patience

@chinesedfan
Copy link
Collaborator

Closed as released.

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants