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

Error: connect ECONNREFUSED 127.0.0.1:4444\n at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14) #63

Closed
shashtrih opened this issue Nov 21, 2019 · 32 comments

Comments

@shashtrih
Copy link

when i configured below package configuration in my project . its throwing this error
npm package use
webdriverio - 5.16.5
wdio-docker-service - 2.1.4

// wdio.conf.js
exports.config = {
// ...
specs: [

'./test/**/01**.js',

],
services: ['docker'],

// Options are set here as well
capabilities: [{
{ browserName: 'chrome'
// chromeOptions: {
// args: debug ? [] : [ '--disable-gpu', '--window-size=1280,800'],
// }
}
}],
dockerLogs: './logs',
dockerOptions: {
image: 'selenium/standalone-chrome',
healthCheck: {
url: 'http://localhost:4444',
maxRetries: 3,
inspectInterval: 1000,
startDelay: 15000
},
options: {
p: ['4444: 4444'],
shmSize: '2g'
}
},

};

//Actual test file
describe(browser.capabilities.browserName + ' - basic test', function() {

    it('should have the right title', async () => {
        await browser.url('https://webdriver.io');
        const title = await browser.getTitle();
        assert.equal(title, 'WebdriverIO · Next-gen WebDriver test framework for Node.js');
    });
});

Error on console
Execution of 1 spec files started at 2019-11-21T05:54:28.504Z

[0-0] RUNNING in chrome - C:\codebase\webdriverio\01-base-test.js
0-0 worker error { name: 'Error',
message: 'connect ECONNREFUSED 127.0.0.1:4444',
stack:
'Error: connect ECONNREFUSED 127.0.0.1:4444\n at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)' }
[0-0] FAILED in chrome - C:\codebase\webdriverio01-base-test.js

Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:06

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Exit status 1
npm ERR!
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@stsvilik
Copy link
Collaborator

Interesting... did this pattern describe(browser.capabilities.browserName + ' - basic test', function() { worked before (in v4 of WDIO)? I believe that this info is printed out by WDIO itself, no? Did you try with just plain text in the describe block?

@zastqa
Copy link

zastqa commented Nov 22, 2019

yes i tried with plain text as well but still same issue
Below is test file
describe('webdriver.io page', () => {
it('should have the right title', async () => {
await browser.url('https://webdriver.io');
const title = await browser.getTitle();
assert.equal(title, 'WebdriverIO · Next-gen WebDriver test framework for Node.js');
});
});

here its details level error
Execution of 1 spec files started at 2019-11-22T00:51:42.786Z

2019-11-22T00:51:42.922Z INFO @wdio/cli:launcher: Run onPrepare hook
2019-11-22T00:51:42.963Z WARN wdio-docker-service: Connecting dockerEventsListener: 13560
2019-11-22T00:51:43.083Z INFO wdio-docker-service: Cleaning up CID files
2019-11-22T00:51:43.142Z WARN wdio-docker-service: NOTE: Pulling image for the first time. Please be patient.
2019-11-22T00:51:43.155Z INFO @wdio/local-runner: Start worker 0-0 with arg: wdioDocker.conf.js
2019-11-22T00:51:43.583Z ERROR wdio-docker-service: Error: Error executing sub-child: docker events --format {{json .}} --filter image=robcherry/docker-chromedriver:latest
at DockerEventsListener._onMessage (C:\Users\hardi\codebase\wdio-docker-service\node_modules\wdio-docker-service\lib\utils\dockerEventsListener.js:67:21)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at emit (internal/child_process.js:772:12)
at _combinedTickCallback (internal/process/next_tick.js:141:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
2019-11-22T00:51:43.583Z WARN wdio-docker-service: Disconnecting dockerEventsListener: 13560
[0-0] 2019-11-22T00:51:44.915Z INFO @wdio/local-runner: Run worker command: run
[0-0] RUNNING in chrome - C:\Users\hardi\codebase\wdio-docker-service\test\specs\basic.js
[0-0] 2019-11-22T00:51:45.631Z INFO webdriverio: Initiate new session using the webdriver protocol
[0-0] 2019-11-22T00:51:45.638Z INFO webdriver: [POST] http://localhost:4444/wd/hub/session
[0-0] 2019-11-22T00:51:45.638Z INFO webdriver: DATA { capabilities:
{ alwaysMatch: { browserName: 'chrome', chromeOptions: [Object] },
firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome', chromeOptions: { args: [Array] } } }
[0-0] 2019-11-22T00:51:47.673Z WARN webdriver: Request failed due to connect ECONNREFUSED 127.0.0.1:4444
[0-0] 2019-11-22T00:51:47.674Z INFO webdriver: Retrying 1/3
2019-11-22T00:51:47.674Z INFO webdriver: [POST] http://localhost:4444/wd/hub/session
[0-0] 2019-11-22T00:51:47.674Z INFO webdriver: DATA { capabilities:
{ alwaysMatch: { browserName: 'chrome', chromeOptions: [Object] },
firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome', chromeOptions: { args: [Array] } } }
[0-0] 2019-11-22T00:51:49.686Z WARN webdriver: Request failed due to connect ECONNREFUSED 127.0.0.1:4444
[0-0] 2019-11-22T00:51:49.687Z INFO webdriver: Retrying 2/3
2019-11-22T00:51:49.687Z INFO webdriver: [POST] http://localhost:4444/wd/hub/session
[0-0] 2019-11-22T00:51:49.687Z INFO webdriver: DATA { capabilities:
{ alwaysMatch: { browserName: 'chrome', chromeOptions: [Object] },
firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome', chromeOptions: { args: [Array] } } }
[0-0] 2019-11-22T00:51:51.693Z WARN webdriver: Request failed due to connect ECONNREFUSED 127.0.0.1:4444
[0-0] 2019-11-22T00:51:51.693Z INFO webdriver: Retrying 3/3
2019-11-22T00:51:51.693Z INFO webdriver: [POST] http://localhost:4444/wd/hub/session
[0-0] 2019-11-22T00:51:51.694Z INFO webdriver: DATA { capabilities:
{ alwaysMatch: { browserName: 'chrome', chromeOptions: [Object] },
firstMatch: [ {} ] },
desiredCapabilities: { browserName: 'chrome', chromeOptions: { args: [Array] } } }
[0-0] 2019-11-22T00:51:53.699Z ERROR webdriver: Request failed due to Error: connect ECONNREFUSED 127.0.0.1:4444
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
[0-0] 2019-11-22T00:51:53.700Z ERROR webdriver: Error: connect ECONNREFUSED 127.0.0.1:4444
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
[0-0] 2019-11-22T00:51:53.700Z ERROR @wdio/runner: Error: Failed to create session.
Unable to connect to "127.0.0.1:4444", make sure browser driver is running on that address.
If you use services like chromedriver see initialiseServices logs above or in wdio.log file.
at startWebDriverSession (C:\Users\hardi\codebase\wdio-docker-service\node_modules\webdriver\build\utils.js:45:11)
at
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
[0-0] Error: Failed to create session.
Unable to connect to "127.0.0.1:4444", make sure browser driver is running on that address.
If you use services like chromedriver see initialiseServices logs above or in wdio.log file.
[0-0] FAILED in chrome - C:\Users\hardi\codebase\wdio-docker-service\test\specs\basic.js
2019-11-22T00:51:53.821Z INFO @wdio/cli:launcher: Run onComplete hook
2019-11-22T00:51:53.822Z INFO wdio-docker-service: Cleaning up CID files
2019-11-22T00:51:53.823Z INFO wdio-docker-service: Docker container has stopped

Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:11

@stsvilik
Copy link
Collaborator

Please try to add runner: 'local' to your config.

@zastqa
Copy link

zastqa commented Nov 22, 2019

Thanks , make changes and rerun test but still having same error

@stsvilik
Copy link
Collaborator

Ok, your error logs indicate that docker events crashed, which in turn means that test runner has probably started before selenium docker was available. Are you running this on Windows?

@zastqa
Copy link

zastqa commented Nov 22, 2019

Yes I am running on windows 10

@stsvilik
Copy link
Collaborator

Ok that explains it - Docker in Windows 10 uses a different command line format. Look at this issue #56. I'm working on a fix. The problem is that I don't have Windows 10 to test on now (Mac only).

@stsvilik
Copy link
Collaborator

I have pushed out an RC version 2.1.5-rc.0 do you mind testing it out on Windows 10?

@shashtrih
Copy link
Author

Sorry for late response but i have tried out yesterday with latest version 2.1.5-rc.0 and .. i have windows 10 home so i have downloaded docker-desktop for that config
but still getting same error , no luck :(

@stsvilik
Copy link
Collaborator

Uhh, could you please set logging: 'debug' and send me the log?

@shashtrih
Copy link
Author

looks like issue with docker on windows , so now docker is running on windows
able to run my test now and it working
now I am not seeing 'ERROR wdio-docker-service: Error: Error executing sub-child: docker events --format {{json .}} ' and also ECONNREFUSED'
thanks much for all support

@stsvilik stsvilik closed this as completed Dec 4, 2019
@shashtrih
Copy link
Author

Hello @stsvilik do you know when should get new tag version(like 2.1.5) created from Release candidate 2.1.5-rc.0

@stsvilik
Copy link
Collaborator

stsvilik commented Dec 6, 2019 via email

@shashtrih
Copy link
Author

Hello @stsvilik do you know other issue owners get chance to test it or any push for new version with this fix .. I am still patient :) but just asking its been 25 days

@stsvilik
Copy link
Collaborator

I'm setting up Windows 10 - should be done with it in a week after holidays :/

@stsvilik
Copy link
Collaborator

stsvilik commented Jan 8, 2020

@shashtrih could you try out newer RC 2.1.5-rc.1?

@VisuSubbaiyan
Copy link

@stsvilik I'm getting the same issue in gitlab CI pipeline. It's running fine in my local.
I'm using "wdio-docker-service": "^2.2.1"

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 4, 2020 via email

@VisuSubbaiyan
Copy link

VisuSubbaiyan commented Feb 4, 2020

@stsvilik Please check the CI log...

$ yarn e2e:regression
 yarn run v1.13.0
 $ REMOTE_BROWSERS=chrome wdio wdio.conf.js --suite=regression
 @babel/preset-env: `DEBUG` option
 Using targets:
 {
   "ie": "11",
   "node": "10.15.3"
 }
 Using modules transform: auto
 Using plugins:
   transform-template-literals { "ie":"11" }
   transform-literals { "ie":"11" }
   transform-function-name { "ie":"11" }
   transform-arrow-functions { "ie":"11" }
   transform-classes { "ie":"11" }
   transform-object-super { "ie":"11" }
   transform-shorthand-properties { "ie":"11" }
   transform-duplicate-keys { "ie":"11" }
   transform-computed-properties { "ie":"11" }
   transform-for-of { "ie":"11" }
   transform-sticky-regex { "ie":"11" }
   transform-dotall-regex { "ie":"11" }
   transform-unicode-regex { "ie":"11" }
   transform-spread { "ie":"11" }
   transform-parameters { "ie":"11" }
   transform-destructuring { "ie":"11" }
   transform-block-scoping { "ie":"11" }
   transform-typeof-symbol { "ie":"11" }
   transform-new-target { "ie":"11" }
   transform-regenerator { "ie":"11" }
   transform-exponentiation-operator { "ie":"11" }
   transform-async-to-generator { "ie":"11" }
   proposal-async-generator-functions { "ie":"11" }
   proposal-object-rest-spread { "ie":"11" }
   proposal-unicode-property-regex { "ie":"11" }
   proposal-json-strings { "ie":"11" }
   proposal-optional-catch-binding { "ie":"11" }
   transform-named-capturing-groups-regex { "ie":"11" }
   transform-modules-commonjs { "ie":"11", "node":"10.15.3" }
   proposal-dynamic-import { "ie":"11", "node":"10.15.3" }
 Using polyfills with `entry` option:
 [/builds/frontend/e2e/capabilities.js] Import of core-js was not found.
 [/builds/frontend/e2e/utils/newProfilePageUtils.js] Import of core-js was not found.
 [/builds/frontend/constants/tracking.js] Import of core-js was not found.
 Execution of 1 spec files started at 2020-01-30T09:46:57.672Z
 2020-01-30T09:46:57.682Z INFO @wdio/cli:launcher: Run onPrepare hook
 2020-01-30T09:46:57.692Z WARN wdio-docker-service: Connecting dockerEventsListener: 276
 2020-01-30T09:46:57.695Z INFO wdio-docker-service: Cleaning up CID files
 2020-01-30T09:46:57.704Z WARN wdio-docker-service: NOTE: Pulling image for the first time. Please be patient.
 2020-01-30T09:46:57.717Z INFO @wdio/local-runner: Start worker 0-0 with arg: wdio.conf.js,--suite=regression
 2020-01-30T09:46:57.798Z ERROR wdio-docker-service: Error: Error executing sub-child: docker events --format {{json\ .}} --filter image=selenium/standalone-chrome
     at DockerEventsListener._onMessage (/builds/frontend/node_modules/wdio-docker-service/lib/utils/dockerEventsListener.js:67:21)
     at ChildProcess.emit (events.js:189:13)
     at ChildProcess.EventEmitter.emit (domain.js:441:20)
     at emit (internal/child_process.js:820:12)
     at process._tickCallback (internal/process/next_tick.js:63:19)
 2020-01-30T09:46:57.798Z WARN wdio-docker-service: Disconnecting dockerEventsListener: 276
 [0-0] 2020-01-30T09:46:58.073Z INFO @wdio/local-runner: Run worker command: run
 [0-0] @babel/preset-env: `DEBUG` option
 [0-0] 
 [/builds/frontend/e2e/utils/newProfilePageUtils.js] Import of core-js was not found.
 [0-0] RUNNING in chrome - /e2e/suites/regression.js
 [0-0] 2020-01-30T09:46:58.837Z INFO webdriverio: Initiate new session using the webdriver protocol
 [0-0] 2020-01-30T09:46:58.839Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session
 [0-0] 2020-01-30T09:46:58.839Z INFO webdriver: DATA { capabilities:
    { alwaysMatch:
       { browserName: 'chrome',
         acceptInsecureCerts: true,
         'goog:chromeOptions': [Object],
         'selenoid:options': [Object] },
      firstMatch: [ {} ] },
   desiredCapabilities:
    { browserName: 'chrome',
      acceptInsecureCerts: true,
      'goog:chromeOptions': { args: [Array] },
      'selenoid:options': { enableVNC: false } } }
 [0-0] 2020-01-30T09:46:58.852Z WARN webdriver: Request failed due to connect ECONNREFUSED 127.0.0.1:4444
 [0-0] 2020-01-30T09:46:58.852Z INFO webdriver: Retrying 1/5
 2020-01-30T09:46:58.853Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session
 [0-0] 2020-01-30T09:46:58.853Z INFO webdriver: DATA { capabilities:
    { alwaysMatch:
       { browserName: 'chrome',
         acceptInsecureCerts: true,
         'goog:chromeOptions': [Object],
         'selenoid:options': [Object] },
      firstMatch: [ {} ] },
   desiredCapabilities:
    { browserName: 'chrome',
      acceptInsecureCerts: true,
      'goog:chromeOptions': { args: [Array] },
      'selenoid:options': { enableVNC: false } } }
 [0-0] 2020-01-30T09:46:58.855Z WARN webdriver: Request failed due to connect ECONNREFUSED 127.0.0.1:4444
 .
 .
 .
 .
 [0-0] 2020-01-30T09:46:58.859Z INFO webdriver: Retrying 5/5
 2020-01-30T09:46:58.859Z INFO webdriver: [POST] http://127.0.0.1:4444/wd/hub/session
 [0-0] 2020-01-30T09:46:58.859Z INFO webdriver: DATA { capabilities:
    { alwaysMatch:
       { browserName: 'chrome',
         acceptInsecureCerts: true,
         'goog:chromeOptions': [Object],
         'selenoid:options': [Object] },
      firstMatch: [ {} ] },
   desiredCapabilities:
    { browserName: 'chrome',
      acceptInsecureCerts: true,
      'goog:chromeOptions': { args: [Array] },
      'selenoid:options': { enableVNC: false } } }
 [0-0] 2020-01-30T09:46:58.861Z ERROR webdriver: Request failed due to Error: connect ECONNREFUSED 127.0.0.1:4444
     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
 [0-0] 2020-01-30T09:46:58.861Z ERROR webdriver: Error: connect ECONNREFUSED 127.0.0.1:4444
     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
 [0-0] 2020-01-30T09:46:58.861Z ERROR @wdio/runner: Error: Failed to create session.
 Unable to connect to "127.0.0.1:4444", make sure browser driver is running on that address.
 If you use services like chromedriver see initialiseServices logs above or in wdio.log file.
     at startWebDriverSession (/builds/frontend/node_modules/webdriver/build/utils.js:45:11)
     at process._tickCallback (internal/process/next_tick.js:68:7)
 [0-0] Error: Failed to create session.
 Unable to connect to "127.0.0.1:4444", make sure browser driver is running on that address.
 If you use services like chromedriver see initialiseServices logs above or in wdio.log file.
 [0-0] FAILED in chrome - /e2e/suites/regression.js
 2020-01-30T09:46:58.972Z INFO @wdio/cli:launcher: Run onComplete hook
 2020-01-30T09:46:58.973Z INFO wdio-docker-service: Cleaning up CID files
 2020-01-30T09:46:58.973Z INFO wdio-docker-service: Docker container has stopped
 Spec Files:	 0 passed, 1 failed, 1 total (100% completed) in 00:00:01 
 2020-01-30T09:46:58.974Z INFO @wdio/local-runner: Shutting down spawned worker
 2020-01-30T09:46:59.226Z INFO @wdio/local-runner: Waiting for 0 to shut down gracefully
 2020-01-30T09:46:59.226Z INFO @wdio/local-runner: shutting down
 error Command failed with exit code 1.
 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
 ERROR: Job failed: exit code 1

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 5, 2020

@VisuSubbaiyan please try with latest version 2.3.0. Thanks!

@VisuSubbaiyan
Copy link

@stsvilik Thank you for your reply, but still, Im having the same issue.

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 5, 2020 via email

@VisuSubbaiyan
Copy link

@stsvilik Yes, It's working fine in my Mac

@stsvilik
Copy link
Collaborator

stsvilik commented Feb 5, 2020 via email

@soumya-contentsquare
Copy link

I am facing exactly the same issue in MAC. I am running through CI-CD pipeline in linux environment docker image

@stsvilik
Copy link
Collaborator

@soumya-contentsquare are you testing a public site or your containerized app?

@soumyaevan
Copy link

I am testing public website. My docker environment is for Chrome

@stsvilik
Copy link
Collaborator

@soumyaevan could you share environment details such as node version, OS?
Is docker installed and working? Is there a special network requirement such as proxy?

Issue above indicates that WDIO is unable to connect with Selenium which runs in the container. Make sure docker port is properly mapped and exposed.

@soumya-contentsquare
Copy link

@stsvilik
node version - 8.12.0
OS - MAC
Docker is added as dev dependency
When running the docker locally in the machine, working perfectly. but while executing from jenkins server it is failing

@lud200
Copy link

lud200 commented Apr 17, 2020

Is this issue resolved? I cannot find any suggested solution in this thread. I am running into similar issues when I try to run from jenkins. Port 4444 is exposed in my Dockerfile
Configs in wdio.conf.js:
services: ['docker'], dockerLogs: './', dockerOptions: { image: 'selenium/standalone-chrome', healthCheck: 'http://localhost:4444', options: { p: ['4444:4444'], addHost: ['dockerhost:localhost'], shmSize: '2g' } },

@stsvilik
Copy link
Collaborator

Sorry for delay. This issue is environment-specific and not easily diagnosed. Jenkins, depending on the setup and configuration could prevent local instances from exposing ports for access or maybe even make calls via localhost. Could you try to use actual host address from env instead of localhost to specify for Selenium host?

@samy777md
Copy link

hello world

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

No branches or pull requests

8 participants