question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Related issues

  • #1885 (that one using a socks proxy, therefor I consider this one to be different)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:13
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
elegisandicommented, Oct 23, 2019

waiting for the new release 😃

4reactions
JitixPhotoboxcommented, Sep 25, 2019

I have opened a PR to fix this issue : https://github.com/axios/axios/pull/2426

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does https.Agent throw a parse error when proxying via ...
(I've elided the complementary http agent for brevity.) I create a proxy server, as such: const proxy = httpProxy.createProxyServer({});.
Read more >
Certificate error when using HTTPS proxy with self-signed ...
It supports self-signed certificates without proxy or proxy with normal CA certificates, but not the combination of proxy + self-signed.
Read more >
How to make HTTPS request through HTTP proxy with Axios
I was passing both HTTPS_PROXY and https_proxy environment variable to docker run in hope that Axios would pick one up but this didn't...
Read more >
http-proxy-middleware - npm
The one-liner node.js proxy middleware for connect, express and browser-sync. Latest version: 2.0.6, last published: 8 months ago.
Read more >
How to use a proxy with node-fetch? - ScrapingBee
Unfortunately, Node-fetch does not natively support proxies. But there is a work-around. By using the node-https-proxy-agent, you will be able ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found