Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Socket hang up behind a proxy #536

Open
ericsakmar opened this issue May 20, 2016 · 10 comments
Open

Socket hang up behind a proxy #536

ericsakmar opened this issue May 20, 2016 · 10 comments

Comments

@ericsakmar
Copy link

Description

socket hang up error when attempting to install behind a proxy.

Steps to Reproduce

.typingsrc contents:

proxy=http://proxy:9999
rejectUnauthorized=false

command:

typings install dt~angular-protractor --save --global

Expected behavior:
a successful install

Actual behavior:

typings ERR! message Unable to read typings for "angular-protractor". You should check the entry paths in "angular-protractor.d.ts" are up to date
typings ERR! caused by Unable to connect to "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/f9c44651705f574f6d4258fe5e1c335462bdcc19/angular-protractor/angular-protractor.d.ts"
typings ERR! caused by socket hang up

typings ERR! system Darwin 14.5.0
typings ERR! command "/usr/local/bin/node" "/usr/local/bin/typings" "install" "dt~angular-protractor" "--save" "--global"
typings ERR! node -v v5.7.0
typings ERR! typings -v 1.0.4

Versions

node -v v5.7.0
typings -v 1.0.4

Thanks for the help!

@R2D2-fwks
Copy link

Hi we are also facing the similar issue but instead of Angular we are doing it for react.

Current version of Nodejs is 4.4
and Typings version 1.0.4

Error Stack:

$ typings install 'dt~react-dom' --save --global
typings ERR! message Unable to connect to "https://api.typings.org/entries/dt/react-dom/versions/latest"
typings ERR! caused by socket hang up

typings ERR! cwd G:\workspace4brackets\typscript-0
typings ERR! system Windows_NT 6.1.7601
typings ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\xxx\AppData\Roaming\npm\node_modules\typings\dist\bin.js" "install" "dt~react-dom" "--sav
e" "--global"
typings ERR! node -v v4.4.4
typings ERR! typings -v 1.0.4
typings ERR! code EUNAVAILABLE

typings ERR! If you need help, you may report this error at:
typings ERR! https://github.com/typings/typings/issues

@bensontrent
Copy link
Contributor

bensontrent commented Jun 26, 2016

in your .typingsrc file set your registry url to use http rather than https. Setting a proxy sets both httpProxy and httpProxy.

.typingsrc

proxy=http://proxy:9999
rejectUnauthorized=false
registryURL=http://api.typings.org/

The full list of allowed settings in .typingsrc is here:

Property Description
proxy A HTTP(s) proxy URI for outgoing requests. Setting this sets both httpProxy and httpsProxy if they are not set, as this is used as a fallback variable if both httpProxy and httpsProxy.
httpProxy Any standard http-proxy as supported by the request package. (default: process.env.HTTP_PROXY). For example, "http://127.0.0.1:8888/" or real proxy from incloak.com/proxy-list/. If your proxy requires authentication, you may need to include a username and password in your url: "http://domain\\myusername:password@myproxyServer:port", or if you are not on an AD domain: "http://username:mypassword@myProxyServer:port"

httpsProxy The proxy to use for HTTPS requests (default: process.env.HTTPS_PROXY).
noProxy A string of space-separated hosts to not proxy (default: process.env.NO_PROXY).
rejectUnauthorized Reject invalid SSL certificates (default: true). Useful behind (corporate) proxies that act like man-in-the middle on https connections. This setting is passed to the request package to handle connection.
ca A string or array of strings of trusted certificates in PEM format.
key Private key to use for SSL.
cert Public x509 certificate to use.
userAgent Set the User-Agent for HTTP requests (default: "typings/{typingsVersion} node{nodeVersion} {platform} {arch}").
githubToken Add your GitHub token for resolving github:* locations. You can create this token on Github.com at https://github.com/settings/tokens/new. The OAuth token can be used to boost the Github API rate-limit from 60 to 5000 (non-cached) requests per hour. This token just needs 'read-only access to public information' so no additional OAuth scopes are necessary. Note: keep in mind the .typingsrc file is not secured. Don't use a token with additional scope unless you know what you are doing.
registryURL Override the registry URL. (Default: "https://api.typings.org".)
defaultSource Override the default installation source (E.g. when doing typings install debug) default: npm). Allowed options: file, npm, github, bitbucket, bower, http, or https

@amellnik
Copy link

amellnik commented Jul 27, 2016

I'm also seeing this issue. My .typingsrc file looks like

httpProxy=http://my.proxy.com:someport
httpsProxy=https://my.proxy.com:adifferentport
rejectUnauthorized=false

Update: needed to use only proxy set to my http proxy. Worked on the second try, unclear why.

@DeanB2015
Copy link

DeanB2015 commented Aug 4, 2016

@bensontrent I was able to verify and your comment works. Thanks for the help!

.typingsrc

proxy=http://http.proxy.domain.com:8000
rejectUnauthorized=false
registryURL=http://api.typings.org/

@magwalls
Copy link

I don't know how many hours we've been struggling to make this work behind a corporate proxy and we're still having issues.

.typingsrc

proxy=http://user:pwd@http.proxy.domain.com:8080 
rejectUnauthorized=false 
registryURL=http://api.typings.org/

This command works fine!
typings search --name react

But this command fails with socket hang up
typings install dt~react

We're getting this message:

typings ERR! message Unable to read typings for "react". You should check the entry paths in "react.d.ts" are up to date
typings ERR! caused by Unable to connect to "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/f9117cf5dd3420b4fcb4342bf287945695a953a4/react/react.d.ts"
typings ERR! caused by socket hang up

node -v v6.2.1
typings -v 1.3.3

@bensontrent
Copy link
Contributor

While you're now able to connect to api.typings.org (via http), it appears you're unable to connect to raw.githubusercontent (via https). I had the same issue before I adding a github token.

You might try something like this, if you're unsuccessful configuring your certificate authority through your firewall:

.typingsrc file

proxy=http://user:pwd@http.proxy.domain.com:8080 
rejectUnauthorized=false 
registryURL=http://api.typings.org/
githubToken=YourVeryLongTokenString

Other registries my require you to connect to other domains, I believe those domains can be routed with a .netrc file. An example .netrc for routing the github.com domain:

.netrc file

# .netrc
## To generate a github token with read only access, see:
## https://help.github.com/articles/creating-an-access-token-for-command-line-use/ 
machine github.com login <token>

@magwalls
Copy link

Thanks for spending your time on this bensontrent. However I'm afraid that creating a github token didn't help. Neither using the file _netrc helped me out. (I read that it should be called _netrc on Windows).

@bensontrent
Copy link
Contributor

bensontrent commented Aug 30, 2016

I think I have a solution.

  1. Take the url from your error code.
    https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/f9117cf5dd3420b4fcb4342bf287945695a953a4/react/react.d.ts
  2. Remove the s from https.
    http://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/f9117cf5dd3420b4fcb4342bf287945695a953a4/react/react.d.ts
  3. Prefix the name of the package to the url.
    react=
  4. Take a lock of hair from behind your ear and put it in the knot of a tree, along with a dish rag. When you are taller than the knot in the tree, you will be cured (This is actual advice from my witty and dearly departed Tennessean grandmother on curing asthma, and inexplicably my cousin swears it's what cured her.). This is step is relevant if you feel this process is witchcraft and you needed confirmation that it is indeed a magic spell. Eh, it's late. :)
  5. Put it all together:
typings install react=http://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/f9117cf5dd3420b4fcb4342bf287945695a953a4/react/react.d.ts --save --global

That should circumvent errors thrown by modified certificates when behind a firewall. Please let your network admin know you are having problems, it's best to use the correct certificate.

@magwalls
Copy link

Thanks again but I'll put this to rest for a while. I can't even get it to work by removing the s from https. Getting 503 when doing so.

Step 4 would be really good but as you can see from my picture I don't have enough hair on my head to be able to take a lock! Darn! :)

Yes, I think I'll have to convince the network department to put some effort in making life a bit easier for the developers in our company.

@bensontrent
Copy link
Contributor

@blakeembrey @magwalls's issue could be best addressed with a modification to the way rejectUnauthorized works. The goal being that any call to a https url uses http instead? Or a new setting called strictSSL? I can put together a pull request in the core package.

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

No branches or pull requests

7 participants