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

ECONNREFUSED when using HTTPS over HTTP proxy #679

Closed
wangzhiwei1888 opened this issue Jan 12, 2017 · 21 comments
Closed

ECONNREFUSED when using HTTPS over HTTP proxy #679

wangzhiwei1888 opened this issue Jan 12, 2017 · 21 comments
Labels
Milestone

Comments

@wangzhiwei1888
Copy link

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/6.9.4"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/opt/yrd_app/node-generator-img-activity/node_modules/sharp/.node-gyp"
ERROR: Download of https://dl.bintray.com/lovell/sharp/libvips-8.4.2-linux-x64.tar.gz failed: connect ECONNREFUSED 35.166.56.1:443
gyp: Call to 'LDD_VERSION="ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
由 Roland McGrath 和 Ulrich Drepper 编写。" node -e "require('./binding').download_vips()"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/root/work/node-v6.9.4-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 3.10.0-327.22.2.el7.x86_64
gyp ERR! command "/root/work/node-v6.9.4-linux-x64/bin/node" "/root/work/node-v6.9.4-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /opt/yrd_app/node-generator-img-activity/node_modules/sharp
gyp ERR! node -v v6.9.4
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok

npm ERR! Linux 3.10.0-327.22.2.el7.x86_64
npm ERR! argv "/root/work/node-v6.9.4-linux-x64/bin/node" "/root/work/node-v6.9.4-linux-x64/bin/npm" "install" "--registry=https://registry.npm.taobao.org"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sharp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sharp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sharp
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /opt/yrd_app/node-generator-img-activity/npm-debug.log

@lovell
Copy link
Owner

lovell commented Jan 12, 2017

Hello, the salient error is ERROR: Download of https://dl.bintray.com/lovell/sharp/libvips-8.4.2-linux-x64.tar.gz failed: connect ECONNREFUSED 35.166.56.1:443

This is a (temporary?) network problem connecting to bintray (within China?) to retrieve the pre-compiled binary of libvips and its dependencies.

@lovell lovell closed this as completed Jan 12, 2017
@lovell lovell changed the title npm install fails for sharp in centos 7.2 ECONNREFUSED npm install fails for sharp in centos 7.2 Jan 12, 2017
@mirow
Copy link

mirow commented Jan 12, 2017

I don't think it's a network problem, because I get the same error message but I can still download the file with curl.

@lovell
Copy link
Owner

lovell commented Jan 12, 2017

@mirow sharp will honour npm's https-proxy setting.

@mirow
Copy link

mirow commented Jan 12, 2017

I'm not using a proxy

@mirow
Copy link

mirow commented Jan 12, 2017

dl.bintray.com retuns a 302 redirect, is that the problem?

@lovell
Copy link
Owner

lovell commented Jan 12, 2017

@mirow I experience no 302 redirects locally:

$ curl -Is https://dl.bintray.com/lovell/sharp/libvips-8.4.2-linux-x64.tar.gz
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 12 Jan 2017 11:17:51 GMT
Content-Type: application/gzip
Content-Length: 6837337
Connection: keep-alive
Last-Modified: Tue, 08 Nov 2016 11:53:17 GMT
Accept-Ranges: none
ETag: 5c0584599f0a1cbe6b63e327f22834d665957e7e298acf4f4e88c13e07a001f0
X-Checksum-Sha1: dd7f800f3ae0e534604845a8689a42ee48757e1c
X-Checksum-Sha2: 5c0584599f0a1cbe6b63e327f22834d665957e7e298acf4f4e88c13e07a001f0

The IP address I'm being served for dl.bintray.com is:

$ dig dl.bintray.com +short
159.122.18.156
$ whois 159.122.18.156
...
inetnum:        159.122.18.128 - 159.122.18.159
netname:        NETBLK-SOFTLAYER-RIPE-CUST-YL827-RIPE
descr:          JFrog
...

The IP address in the original error report is:

$ whois 35.166.56.1
...
Amazon Technologies Inc. AT-88-Z (NET-35-152-0-0-1) 35.152.0.0 - 35.183.255.255
Amazon.com, Inc. AMAZO-ZPDX9 (NET-35-160-0-0-1) 35.160.0.0 - 35.167.255.255
...

which suggests some kind of DNS poisoning or MITM.

@mirow
Copy link

mirow commented Jan 12, 2017

Nevermind, my reason was different (glibc version) even though the error message was the same "node -e "require('./binding').download_vips()"' returned exit status 1

@wangzhiwei1888
Copy link
Author

I am in china .my macbook ok,windows ok,test server is centos 7.2 no ok.
in centos 7.2
[root@infra-wordpress node-generator-img-activity]# curl -Is https://dl.bintray.com/lovell/sharp/libvips-8.4.2-linux-x64.tar.gz
HTTP/1.0 200 Connection established

HTTP/1.1 200 OK
Server: nginx
Date: Fri, 13 Jan 2017 01:07:48 GMT
Content-Type: application/gzip
Content-Length: 6837337
Connection: keep-alive
Last-Modified: Tue, 08 Nov 2016 11:53:17 GMT
Accept-Ranges: none
ETag: 5c0584599f0a1cbe6b63e327f22834d665957e7e298acf4f4e88c13e07a001f0
X-Checksum-Sha1: dd7f800f3ae0e534604845a8689a42ee48757e1c
X-Checksum-Sha2: 5c0584599f0a1cbe6b63e327f22834d665957e7e298acf4f4e88c13e07a001f0

@lovell
Copy link
Owner

lovell commented Jan 13, 2017

@wangzhiwei1888 The double HTTP in the response suggests there's a proxy involved here.

HTTP/1.0 200 Connection established
HTTP/1.1 200 OK

Perhaps this is attempting to tunnel HTTPS over HTTP? Does the following make any difference?

NODE_TLS_REJECT_UNAUTHORIZED=0 npm install sharp

@wangzhiwei1888
Copy link
Author

my company test service can not to connect web ,must proxy to one service . is the reason?

@lovell
Copy link
Owner

lovell commented Jan 13, 2017

@wangzhiwei1888 Yes, very likely. sharp depends on get-proxy to find it. Perhaps check the proxy is capable of proxying HTTPS connections?

@wangzhiwei1888
Copy link
Author

but
'curl -Is https://dl.bintray.com/lovell/sharp/libvips-8.4.2-linux-x64.tar.gz
HTTP/1.0 200 Connection established'

is ok

@wangzhiwei1888
Copy link
Author

this is https

@lovell
Copy link
Owner

lovell commented Jan 13, 2017

@wangzhiwei1888 Please can you provide the output of the following commands when run on the machine that is failing to proxy:

env | grep -i proxy
npm config list | grep -i proxy

@lovell lovell reopened this Jan 13, 2017
@wangzhiwei1888
Copy link
Author

[root@infra-wordpress node-generator-img-activity]# env | grep -i proxy
http_proxy=http://10.141.4.120:8000
https_proxy=http://10.141.4.120:8000
[root@infra-wordpress node-generator-img-activity]# npm config list | grep -i proxy

@lovell
Copy link
Owner

lovell commented Jan 13, 2017

@wangzhiwei1888 Thank you. I suspect the problem here is the HTTPS proxy being via a non-TLS HTTP connection.

Are you able to make the following change to binding.js#L101 and test locally?

- const gotOpt = {};
- if (process.env.npm_config_https_proxy) {
-    // Use the NPM-configured HTTPS proxy
-    gotOpt.agent = caw(process.env.npm_config_https_proxy);
- }
+ const agent = caw(null, { protocol: 'https' });
+ const gotOpt = { agent: agent };

@lovell lovell added triage and removed question labels Jan 13, 2017
@lovell lovell changed the title ECONNREFUSED npm install fails for sharp in centos 7.2 ECONNREFUSED when using HTTPS over HTTP proxy Jan 13, 2017
@wangzhiwei1888
Copy link
Author

sorroy , i dont know .
you mean
1、I git clone https://github.com/lovell/sharp.git to my node_modules
2、change the binding.js
???

@lovell
Copy link
Owner

lovell commented Jan 13, 2017

Sorry for the confusion. Please can you try making your project's package.json dependent on the https-over-http branch:

  ...
  "dependencies": {
    "sharp": "lovell/sharp#https-over-http"
  },
  ...

@wangzhiwei1888
Copy link
Author

thank you very match . the question is solved. welcome to china .

@lovell lovell added bug and removed triage labels Jan 14, 2017
@lovell lovell added this to the v0.17.1 milestone Jan 14, 2017
@lovell
Copy link
Owner

lovell commented Jan 14, 2017

@wangzhiwei1888 Thank you for confirming. This addition will be included in v0.17.1.

@lovell
Copy link
Owner

lovell commented Jan 15, 2017

sharp v0.17.1 now available.

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

No branches or pull requests

3 participants