atom / apm

Atom Package Manager
https://atom.io/packages
MIT License
1.27k stars 297 forks source link

Cannot install packages behind proxy: "tunneling socket could not be established, cause=socket hang up" #611

Open stmax82 opened 8 years ago

stmax82 commented 8 years ago

I'm behind my company's proxy server. I think I configured it correctly, but I'm getting the following error when I try to install packages: "tunneling socket could not be established, cause=socket hang up"

C:\Users\john.doe>apm --version
apm  1.12.5
npm  3.10.5
node 4.4.5
python 3.5.2
git 2.7.0.windows.1
visual studio 2013
C:\Users\john.doe>apm config list
; cli configs
globalconfig = "C:\\Users\\john.doe\\.atom\\.apm\\.apmrc"
user-agent = "npm/3.10.5 node/v4.4.5 win32 ia32"
userconfig = "C:\\Users\\john.doe\\.atom\\.apmrc"

; environment configs
node-gyp = "C:\\Users\\john.doe\\AppData\\Local\\atom\\app-1.10.2\\resources\\app\\apm\\bin\\\\..\\node_modules\\node-gyp\\bin\\node-gyp.js"

; userconfig C:\Users\john.doe\.atom\.apmrc
http-proxy = "http://www-proxy.company.com:8080"
https-proxy = "https://www-proxy.company.com:8080/"
strict-ssl = false

; globalconfig C:\Users\john.doe\.atom\.apm\.apmrc
cache = "C:\\Users\\john.doe\\.atom\\.apm"
progress = false

; node bin location = C:\Users\john.doe\AppData\Local\atom\app-1.10.2\resources\app\apm\bin\node.exe
; cwd = C:\Users\john.doe
; HOME = C:\Users\john.doe
; "npm config ls -l" to show all defaults.
C:\Users\john.doe>apm install uber-juno --verbose
Installing uber-juno to C:\Users\john.doe\.atom\packages REQUEST { url: 'https://atom.io/api/packages/uber-juno',
  json: true,
  retries: 4,
  proxy: 'https://www-proxy.company.com:8080/',
  strictSSL: false,
  headers: { 'User-Agent': 'npm/3.10.5 node/v4.4.5 win32 ia32' },
  callback: [Function],
  method: 'GET' }
REQUEST make request https://atom.io/api/packages/uber-juno
REQUEST { url: 'https://atom.io/api/packages/uber-juno',
  json: true,
  retries: 4,
  proxy: 'https://www-proxy.company.com:8080/',
  strictSSL: false,
  headers: { 'User-Agent': 'npm/3.10.5 node/v4.4.5 win32 ia32' },
  callback: [Function],
  method: 'GET' }
REQUEST make request https://atom.io/api/packages/uber-juno
REQUEST { url: 'https://atom.io/api/packages/uber-juno',
  json: true,
  retries: 4,
  proxy: 'https://www-proxy.company.com:8080/',
  strictSSL: false,
  headers: { 'User-Agent': 'npm/3.10.5 node/v4.4.5 win32 ia32' },
  callback: [Function],
  method: 'GET' }
REQUEST make request https://atom.io/api/packages/uber-juno
REQUEST { url: 'https://atom.io/api/packages/uber-juno',
  json: true,
  retries: 4,
  proxy: 'https://www-proxy.company.com:8080/',
  strictSSL: false,
  headers: { 'User-Agent': 'npm/3.10.5 node/v4.4.5 win32 ia32' },
  callback: [Function],
  method: 'GET' }
REQUEST make request https://atom.io/api/packages/uber-juno
REQUEST { url: 'https://atom.io/api/packages/uber-juno',
  json: true,
  retries: 4,
  proxy: 'https://www-proxy.company.com:8080/',
  strictSSL: false,
  headers: { 'User-Agent': 'npm/3.10.5 node/v4.4.5 win32 ia32' },
  callback: [Function],
  method: 'GET' }
REQUEST make request https://atom.io/api/packages/uber-juno
failed
Request for package information failed: tunneling socket could not be established, cause=socket hang up (5 attempts) (ECONNRESET)

For comparison - git works fine with the same proxy settings:

C:\Users\john.doe>git config --list
core.symlinks=false
core.autocrlf=false
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
user.name=john.doe
user.email=john.doe@gmail.com
http.proxy=http://john.doe:foobar1234!@www-proxy.company.com:8080
http.sslverify=false
https.proxy=https://john.doe:foobar1234!@www-proxy.company.com:8080
https.sslverify=false
C:\Users\john.doe>git clone https://github.com/Theano/Theano.git
Cloning into 'Theano'...
remote: Counting objects: 138592, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 138592 (delta 4), reused 0 (delta 0), pack-reused 138581
Receiving objects: 100% (138592/138592), 55.15 MiB | 1.09 MiB/s, done.
Resolving deltas: 100% (110189/110189), done.
Checking connectivity... done.
jchaps commented 7 years ago

Not sure if this will help you, but for my company's proxy I found that the https-proxy worked when traversing http, but not when traversing https.

So, here's how I have the proxies set in apm config:

http-proxy = "http://www-proxy.company.com:8080/" https-proxy = "http://www-proxy.company.com:8080/"

Note that both proxies are pointed to http...

pheerai commented 7 years ago

Setting http-proxy and https-proxy both to http:// doesn't work for me, but unsetting both and instead setting proxy does, although not with SSL.

This makes atom de-facto unusable for me, as I'm not keen on sending my credentials out in plaintext…

Jaakk0S commented 7 years ago

On Ubuntu 14.04, this does NOT work (I have a local proxy in 3128 that also configures my credentials):

HTTP-PROXY = "http://localhost:3128" HTTPS-PROXY = "https://localhost:3128" HTTPS_PROXY = "http://localhost:3128" HTTP_PROXY = "http://localhost:3128" PROXY = "http://localhost:3128" http-proxy = "http://localhost:3128" http_proxy = "http://localhost:3128" https-proxy = "https://localhost:3128/" https_proxy = "https://localhost:3128" proxy = "http://localhost:3128/" strict-ssl = false

This DOES work:

proxy = "http://localhost:3128/" strict-ssl = false

Conclusion: some of the proxy variables are CONFLICTING.

Anyway, works for me now.

Vilmir commented 7 years ago

@Jaakk0S same problem for me on Windows 7, your solution worked. Thanks!

Super169 commented 7 years ago

@Jaakk0S, thanks a lot. Your solution works in my Windows 7 x64 also.

It'd be better if someone can help to update the information here: https://github.com/atom/apm#using-a-proxy

rfletche847 commented 7 years ago

I concur with the last few folks. On windows 7 @Jaakk0S changes worked behind my corp fw as well.

ethernal commented 7 years ago

I posted the same here: https://github.com/atom/apm/issues/678 But this topic is still open.

One important and MAJOR thing - should be documented BTW.

If you are using Atom in portable mode and are behind a proxy and if you managed to make APM work for default directory (ex. use config below for that) (not your portable one) do this:

this is generally bulletproof way to make Atom work behind proxy I use cntlm as well as my proxy requires NTLM auth.

.apmrc

config=https-proxy
strict-ssl=false
registry=http://registry.npmjs.org/
http-proxy=http://127.0.0.1:3128
https-proxy=http://127.0.0.1:3128
http_proxy=http://127.0.0.1:3128
https_proxy=http://127.0.0.1:3128
proxy=http://127.0.0.1:3128

put that config file in your .atom sibling directory. Proxy will be respected and you'll be able to use "portable" atom.

This basically destroys Portable mode as its not portable anymore. Also electonUserData hangs Atom but that was referenced in some other ticket.

Since apm has to be run from its bin directory in portable Atom folder open a console and temporarly set ATOM_HOME var. ([Request] apm should do this by itself if run from portable install)

SET ATOM_HOME=x:\atom\.atom
apm install <package>

Ps2. APM should get ability to detect if it's behind proxy and use appropriate config if present as this prevents Atom from being truly portable. Who can I ping to notify about the issue and solution?

This should be put into Potable mode documentation.

pbakondy commented 7 years ago

I have the same issue on Mac

iMac:~ pbakondy$ apm update
Package Updates Available (8)
├── angularjs 0.3.5 -> 0.4.0
├── atom-beautify 0.29.14 -> 0.29.22
├── atom-typescript 10.1.13 -> 11.0.2
├── editorconfig 2.0.5 -> 2.2.2
├── linter 1.11.18 -> 2.1.4
├── minimap 4.25.7 -> 4.27.1
├── seti-icons 1.3.4 -> 1.4.3
└── todo-show 1.8.0 -> 1.11.0

Would you like to install these updates? (yes) 

Installing angularjs@0.4.0 to /Users/pbakondy/.atom/packages 
gyp info it worked if it ends with ok
gyp info using node-gyp@3.4.0
gyp info using node@6.9.5 | darwin | x64
gyp http GET https://atom.io/download/electron/v1.3.13/iojs-v1.3.13.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! install error 
gyp ERR! stack Error: tunneling socket could not be established, cause=socket hang up
gyp ERR! stack     at ClientRequest.onError (/Applications/Atom.app/Contents/Resources/app/apm/node_modules/tunnel-agent/index.js:177:17)
gyp ERR! stack     at ClientRequest.g (events.js:291:16)
gyp ERR! stack     at emitOne (events.js:96:13)
gyp ERR! stack     at ClientRequest.emit (events.js:188:7)
gyp ERR! stack     at Socket.socketOnEnd (_http_client.js:346:9)
gyp ERR! stack     at emitNone (events.js:91:20)
gyp ERR! stack     at Socket.emit (events.js:185:7)
gyp ERR! stack     at endReadableNT (_stream_readable.js:974:12)
gyp ERR! stack     at _combinedTickCallback (internal/process/next_tick.js:74:11)
gyp ERR! stack     at process._tickCallback (internal/process/next_tick.js:98:9)
gyp ERR! System Darwin 16.4.0
gyp ERR! command "/Applications/Atom.app/Contents/Resources/app/apm/bin/node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/node-gyp/bin/node-gyp.js" "install" "--runtime=electron" "--target=1.3.13" "--dist-url=https://atom.io/download/electron" "--arch=x64" "--ensure" "--proxy=http://192.168.150.11:8080/"
gyp ERR! cwd /Users/pbakondy/.atom
gyp ERR! node -v v6.9.5
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 

iMac:~ pbakondy$ node -v
v7.7.1

iMac:~ pbakondy$ npm -v
4.1.2

iMac:~ pbakondy$ apm -v
apm  1.16.1
npm  3.10.5
node 6.9.5 x64
python 2.7.13
git 2.12.2

iMac:~ pbakondy$ atom --version
Atom    : 1.16.0
Electron: 1.3.13
Chrome  : 52.0.2743.82
Node    : 6.5.0
RishiKulshreshtha commented 7 years ago

I've simply added this and worked like charm! apm config set proxy http://localhost:3128

Where I've replaced my Proxy IP provided by the organisation instead of localhost. Currently using macOS Sierra

replysam2009 commented 7 years ago

Here is what I did: I navigated to C:\Users\459042.atom. There I found .apmrc file. I updated the file as follows: https-proxy=https://[user]:[password]@[proxy link]:[proxy port] http-proxy=http://[user]:[password]@[proxy link]:[proxy port] proxy=http://[user]:[password]@[proxy link]:[proxy port] strict-ssl=false registry=https://registry.npmjs.org

Example: http://123456:abc123!@proxy.company.com:6070

cniweb commented 7 years ago

Can we use registry=http://nexus.lan.mycompany for a local repository manager (Sonatype Nexus)?

jrweinb commented 6 years ago

What worked for me: ONLY setting http proxy and no strict-ssl. Do not set https-proxy.

SO... open ~/.atom/.apmrc. And set it to:

proxy=http://:/ strict-ssl=false

jheidlage1222 commented 6 years ago

@jrweinb I've been having problems with npm and the angular/cli and unsetting https-proxy from both npmrc and yarnrc as well as setting proxy and strict-ssl false did the trick. Thanks brother.

firesh-bakhda commented 5 years ago

What worked for me: ONLY setting http proxy and no strict-ssl. Do not set https-proxy.

SO... open ~/.atom/.apmrc. And set it to:

proxy=http://:/ strict-ssl=false

Thank you !.. inserting only HTTP proxy and not HTTPS works for me

cniweb commented 5 years ago

This work´s not for us! We need a "proxy" repository (like Nexus or Artefactory).

vincentchu-fr commented 5 years ago

I've simply added this and worked like charm! apm config set proxy http://localhost:3128

Where I've replaced my Proxy IP provided by the organisation instead of localhost. Currently using macOS Sierra

apm config set proxy http://my_proxy:my_port

this worked for me, under linux, with atom 1.33.0

ionutSergiuP commented 5 years ago

Try this complicated configuration:**** Copy content in .npmrc file at path C:\users\yourUser\.npmrc Hint: replace username, password, ip/hostname and port

proxy=http://username:password@ip:port/ allow-same-version=false always-auth=false also=null audit=true audit-level=low auth-type=legacy bin-links=true browser=null ca=null cafile=D:\Angular\undefined cache=C:\Users\username\AppData\Roaming\npm-cache cache-lock-stale=60000 cache-lock-retries=10 cache-lock-wait=10000 cache-max=0 cache-min=10 cert=null cidr=null color=true depth=0 description=true dev=false dry-run=false editor=notepad.exe engine-strict=false force=false fetch-retries=2 fetch-retry-factor=10 fetch-retry-mintimeout=10000 fetch-retry-maxtimeout=60000 git=git commit-hooks=true global=false globalconfig=C:\Users\username\AppData\Roaming\npm\etc\npmrc global-style=false group=0 ham-it-up=false heading=npm if-present=false ignore-prepublish=false ignore-scripts=false init-module=C:\Users\usernamen1804.npm-init.js init-author-name= init-author-email= init-author-url= init-version=1.0.0 init-license=ISC json=false key=null legacy-bundling=false link=false local-address=undefined loglevel=notice logs-max=10 long=false maxsockets=50 message=%s metrics-registry=null node-options=null node-version=10.13.0 offline=false onload-script=null only=null optional=true otp=null package-lock=true package-lock-only=false parseable=false prefer-offline=false prefer-online=false prefix=C:\Program Files\nodejs preid= progress=true https-proxy=null noproxy=null user-agent=npm/{npm-version} node/{node-version} {platform} {arch} read-only=false registry=https://registry.npmjs.org/ rollback=true save=true save-dev=false save-exact=false save-optional=false save-prefix=^ save-prod=false scope= script-shell=null scripts-prepend-node-path=warn-only searchopts= searchexclude=null searchlimit=20 searchstaleness=900 send-metrics=false shell=C:\windows\system32\cmd.exe shrinkwrap=true sign-git-commit=false sign-git-tag=false sso-poll-frequency=500 sso-type=oauth strict-ssl=true tag=latest tag-version-prefix=v timing=false tmp=C:\Users\username\AppData\Local\Temp unicode=false unsafe-perm=true update-notifier=true usage=false user=0 userconfig=C:\Users\username.npmrc umask=0 version=false versions=false viewer=browser _exit=true globalignorefile=C:\Users\\AppData\Roaming\npm\etc\npmignore python=/path/to/executable/python2.7

Should work ! ;)

contang0 commented 5 years ago

How come Atom updates itself just fine behind corporate proxies, but apm doesn't work?

I'm still getting "tunneling socket could not be established, statusCode=407" in package manager, but Atom just updated to 1.40... sense... this makes none.

carlosloaiza21 commented 5 years ago

Hi, I had the same problem but I found an alternative first search the plug-in and then open it's repo in GitHub then I cloned it into packages folder and then run npm install, I hope this works for you :v:

contang0 commented 5 years ago

@carlosloaiza21 , unfortunately not, because of dependencies.

akshayupendran commented 5 years ago

@Jaakk0S Thank you so much -> your solution worked for me.