ecain
ecain

Reputation: 1302

Connection error with Protractor - Angular CLI

I built an Angular 4 project using Angular CLI and am trying to run the default Protractor tests using the command ng e2e. When I run it, I initially get a successful compilation, but then after about 20 seconds, regardless of whether I do anything I get this error in my terminal:

events.js:160 throw er; // Unhandled 'error' event

Error: connect ETIMEDOUT 172.217.10.80:443 at Object.exports._errnoException (util.js:1018:11)at exports._exceptionWithHostPort (util.js:1041:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)

In my Chrome console I get this error:

zone.js:2616 GET http://localhost:49155/sockjs-node/info?t=1501623806543 net::ERR_CONNECTION_REFUSED

I don't have any of these issue with my "regular" project on port 4200.

Upvotes: 2

Views: 974

Answers (2)

Gi1ber7
Gi1ber7

Reputation: 682

You should be able to set environment variables in order to enable the download behind a corporate proxy:

 SET https_proxy=http://www-proxy.corporate.com:80 *
 SET http_proxy=http://www-proxy.corporate.com:80 *

Also, this approach is more convenience if you need to specify credentials for your proxy, like this:

SET https_proxy=http://yourUserName:yourPassword@www-proxy.corporate.com:80

  • Remember to replace http://www-proxy.corporate.com:80 with actual proxy value. This is a temporary fix as it may be cleared on the computer re-start. For a more permanent approach you can follow the instructions on this link:

Can't run Angular > 2 e2e using protractor behind a proxy

Upvotes: 1

vineetk27
vineetk27

Reputation: 111

@ecain,

When you do ng e2e it runs the webdriver-manager update command and it download webdriver dependency from network. In your case it was blocked on network. You can try to set proxy in protractor.conf.js as below:

capabilities: {
'browserName': 'chrome',
'proxy': {
'proxyType': 'manual',
'httpProxy': 'http://proxy.abc.com:8080'}

If it will work in your case you can see output like below when run ng e2e on console

webpack: Compiled successfully.
[19:46:41] I/update - chromedriver: unzipping chromedriver_2.33.zip
[19:46:41] I/launcher - Running 1 instances of WebDriver
[19:46:41] I/direct - Using ChromeDriver directly...

DevTools listening on ws://127.0.0.1:12629/devtools/browser/01b4e971-94f1-
484a-87bc-ec9f41f30959
Jasmine started

If above solution does not work then set the proxy in system environment variable with key http_proxy and remove proxy inside from npm if it is set globally.Command to delete the proxy inside npm is: npm config delete proxy

Upvotes: 0

Related Questions