download icon indicating copy to clipboard operation
download copied to clipboard

Support proxies

Open totof129 opened this issue 9 years ago • 24 comments

download should call got module using tunnel agent when user is behind a corporate proxy

totof129 avatar Jun 09 '15 15:06 totof129

PR for got module is very welcome. https://github.com/sindresorhus/got/issues/7#issuecomment-68736680

shinnn avatar Jun 10 '15 18:06 shinnn

:+1:

alfonso-presa avatar Jun 15 '15 13:06 alfonso-presa

@alfonso-presa Have you read my comment?

shinnn avatar Jun 15 '15 13:06 shinnn

Yes. I did what I could in the PR I just submitted :-).

Truth is that this was working perfectly last year but when 4.0.0 got released it stated breaking imagemin on our build pipeline... I'm trying my best to fix the problem without having the full node support proxies natively.

alfonso-presa avatar Jun 15 '15 13:06 alfonso-presa

@alfonso-presa, yea, I used the request module here before but decided to switch to got instead because of performance. I don't think the proxy stuff belongs in got anyway.

kevva avatar Jun 16 '15 17:06 kevva

Any progress here? Since this busted, we can no longer run npm install on most of our production apps.

alexpaluzzi avatar Jul 29 '15 20:07 alexpaluzzi

Could someone test this?

kevva avatar Jul 31 '15 12:07 kevva

I'm currently traveling, but I'll test it ASAP

alfonso-presa avatar Jul 31 '15 12:07 alfonso-presa

@kevva Doesn't seem to be working. I just tested (making sure any cached copies were nuked out). It is only using 4.2.0.

Still failing to download through https.

It's worth mentioning, I'm not technically using a "proxy." I do, however, have SSL inspection down the line. Everything worked perfectly on 4.1.2.

alexpaluzzi avatar Jul 31 '15 14:07 alexpaluzzi

@kevva I'm here to test if you need me, I'll be here all day. Whatever I can do to help.

alexpaluzzi avatar Jul 31 '15 14:07 alexpaluzzi

FWIW just tried the current master with the following example:

var Download = require('./');

new Download({mode: '755'})
    .get('https://github.com/kevva/elm-bin/blob/2.0.0/vendor/win/elm-platform-win.tar.gz')
    .dest('downloads')
    .run(function(err, files) {
        if (err) console.log(err);
        console.log(files);
    });

Produced the following:

{ [GotError: Request to https://github.com/kevva/elm-bin/blob/2.0.0/vendor/win/elm-platform-win.tar.gz failed]
  nested: { [Error: tunneling socket could not be established, cause=Parse Error] code: 'ECONNRESET' },
  code: 'ECONNRESET'}

teehemkay avatar Aug 10 '15 14:08 teehemkay

Any news about this? We still have problems with imagemin building because of this. I tried switching from 'got' to 'request' which worked fine in our environment. Was it that much of a performance problem?

mbrand avatar Nov 24 '15 09:11 mbrand

So, when I try to download via https like this:

var Download = require('download');
new Download().get('https://raw.github.com/imagemin/optipng-bin/v3.0.3/vendor/osx/optipng').dest('tmp').run()

it works, but when I set a proxy:

https_proxy=http://mylocalproxy:3128 node download.js

and look at the network traffic, I see that it tells the proxy to connect to port 80:

CONNECT raw.github.com:80 HTTP/1.1

but it then continues to talk SSL, which of course confuses the server completely.

It works when I specify the port in the github url above: https://raw.github.com:443/...

This seems to be a problem in tunnel-agent, which fails to set the defaultPort to 443 for it's https agents... (maybe this issue?)

marc-guenther avatar Nov 24 '15 21:11 marc-guenther

mikeal/tunnel-agent#15 fixed this problem for us.

marc-guenther avatar Nov 25 '15 12:11 marc-guenther

@marc-guenther Great work!

Even if https://github.com/mikeal/tunnel-agent/pull/15 is merged, we should add some tests to check if this module can handle proxy setting correctly. Currently this project doesn't have any tests related to proxy. https://github.com/kevva/download/blob/429f255af0a30609e19b547ad603cacbba8653da/test/test.js

Could anyone help us? I'm not very good at network and HTTP/HTTPS.

shinnn avatar Nov 25 '15 12:11 shinnn

@marc-guenther sorry for the silly question, but does your fix on tunnel-agent works with the current release of download or do you need to include tunnel-agent explicitly as it was proposed in the current open pull request #65 ? I'm also stuck behind a corporate proxy trying to resolve dependencies such as https://github.com/imagemin/jpegtran-bin that use download internally to download the binaries and would like to try it out with your fix but I'm lost on how to do it in a simple way. Can you give me some clues ?

wiibaa avatar Dec 08 '15 08:12 wiibaa

@wiibaa well, we built the fixed tunnel-agent locally, and uploaded it to our Nexus as 0.4.1-hotfix version and added that our shrinkwrap. Since than we had no problems with proxy anymore... The #65 pull request basically tries to do the same thing (explicitly setting the port), but only for this specific module, as the real problem is in tunnel-agent

marc-guenther avatar Dec 08 '15 10:12 marc-guenther

@shinn Good idea. Unfortunately I don't know nothing about Node, so I will leave this for someone more knowledgeable :) Also, there are no tests whatsoever in tunnel-agent, so I don't really know where to put them....

marc-guenther avatar Dec 08 '15 10:12 marc-guenther

@marc-guenther thanks for confirming that shrinkwrap is the only way. I will try this out soon

wiibaa avatar Dec 08 '15 11:12 wiibaa

New version of [email protected] has just been released. This contains the mikeal/tunnel-agent#15 fix. :-)

marc-guenther avatar Dec 08 '15 20:12 marc-guenther

@alexpaluzzi Can you check if https://github.com/kevva/download/issues/64#issuecomment-126704776 is fixed?

shinnn avatar Dec 08 '15 20:12 shinnn

I'm constantly getting this error when I set proxy property:

tunneling socket could not be established, cause=connect EHOSTUNREACH 0.0.31.144:80 - Local (10.10.0.5:56041)

And the code I use is

new Download({
      extract: true,
      proxy: 'http://101.127.219.182:8080',
    })

plrthink avatar May 14 '16 16:05 plrthink

@plrthink I googled here since I had the same problem when trying to install gifsicle in terminal of OS X behind proxy. The weird IP 0.0.31.144 was also print. It is caused by the http_proxy set in ~/.bash_profile. The protocol (http e.g.) should be added before host:port. So the http_proxy should be protocal://host:port instead of host:port。It seems the command apt-get in ubuntu will also encounter this problem.Reference is here. Hope it helps.

lemures-t avatar Sep 07 '16 06:09 lemures-t

You'll need to handle self-signed certificates too.

Jackbennett avatar Jan 16 '17 14:01 Jackbennett