Protractor: Protractor test execution causes EADDRINUSE error

Created on 15 Aug 2017  Â·  4Comments  Â·  Source: angular/protractor

Hi!

I am getting error Error: EADDRINUSE connect EADDRINUSE 127.0.0.1:60267 every time when I am running my UI tests in parallel.
Below are more details about conf.js and errorlog.

Bug report

  • Node Version: 4.5.0
  • Protractor Version: 4.0.14
  • Angular Version: 1.X
  • Browser(s): Chrome 2.29
  • Operating System and Version : Win server 2008 R2

  • Your protractor configuration file
    // babel-register allows for ES6 in Protractor test scripts
    require('babel-register');

exports.config = {

directConnect: true,
chromeDriver: './4_utilsObjects/chromedriver_2.29.exe',

allScriptsTimeout: 180000,

framework: 'jasmine',

specs: ['launcher1.js','launcher2.js'],

rootElement: '[ng-app="preApp"]',

capabilities: {
    'browserName': 'chrome',
    'chromeOptions': {
        // needed to disable saving passwords in account creation tests
        'prefs': {
            'credentials_enable_service': false,
            'profile': {
                'password_manager_enabled': false
            }
        }
    },
    shardTestFiles: true,
    maxInstances: 2,
},

// Jasmine timeout is defined here overriding default Protractor timeout
jasmineNodeOpts: {
    silent: true,
    defaultTimeoutInterval: 180000,
    // needed for jasmine-spec-reporter
    print: function () {
    }
},

onPrepare: () => {
    // here we're adding real time jasmine reporter that will display test steps
    // see https://github.com/bcaudan/jasmine-spec-reporter
    var SpecReporter = require('jasmine-spec-reporter');
    // add jasmine spec reporter
    jasmine.getEnv().addReporter(new SpecReporter({
        displayStacktrace: 'none',
        displaySuccessfulSpec: true,
        displayFailedSpec: true,
        displaySpecDuration: true,
        displaySuiteNumber: true,
        displayPendingSummary: false,
        displayPendingSpec: false
    }))

    // adding Jasmine JUnit reporter
    var jasmineReporters = require('jasmine-reporters');
    jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
        consolidateAll: true,
        savePath: 'reports/JUnitReporter',
        filePrefix: 'testresults'
    }))

    // reporter for TeamCity, enabled only in CI
    if (process.env.TEAMCITY_VERSION)
    {
        jasmine.getEnv().addReporter(new jasmineReporters.TeamCityReporter());
    }

    // Disable animations so e2e tests run faster
    var disableNgAnimate = function () {
        angular.module('disableNgAnimate', []).run(['$animate',function ($animate) {
            $animate.enabled(false);
        }]);
    }
    browser.addMockModule('disableNgAnimate', disableNgAnimate);

    // reporter taking screenshots when failed assertion is spotted, comment out to speed up test run
    var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
    jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
        savePath: 'reports/screenshotReporter/',
        takeScreenshotsOnlyOnFailures: true,
    }))
}

};

  • Output from running the test : Failed: EADDRINUSE connect EADDRINUSE 127.0.0.1:60267
    Error: EADDRINUSE connect EADDRINUSE 127.0.0.1:60267
    at ClientRequest. (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:381:15)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at Socket.socketErrorListener (_http_client.js:269:9)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1269:8)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)
    From: Task: Protractor.waitForAngular() - Locator: By(css selector, div.ng-hide[data-ng-show="spinner"])
    at Driver.schedule (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:377:17)
    at ProtractorBrowser.executeAsyncScript_ (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\built\browser.js:235:28)
    at runWaitForAngularScript (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\built\browser.js:263:30)
    at ProtractorBrowser.waitForAngular (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\built\browser.js:269:16)
    at ElementArrayFinder.getWebElements (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\built\element.js:167:29)
    at ElementFinder.isPresent (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\built\element.js:1037:46)
    at C:\BuildAgent10-1\work\e307a028e92341bb\Cinema.Web\UIAutomation\4_utilsObjects\pageUtils.js:199:75
    at C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:716:14
    at TaskQueue.execute_ (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14)
    at TaskQueue.executeNext_ (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21)
    From: Task:
    at null.pollCondition [as _onTimeout] (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2359:16)
    at Timer.listOnTimeout (timers.js:92:15)
    From: Task:
    at ControlFlow.wait (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2352:17)
    at Driver.wait (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:712:29)
    at ProtractorBrowser.to.(anonymous function) [as wait] (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\built\browser.js:62:29)
    at PageUtils.waitForSpinnerFinished (C:\BuildAgent10-1\work\e307a028e92341bb\Cinema.Web\UIAutomation\4_utilsObjects\pageUtils.js:198:17)
    at PurchasePage.clickOnContinueButton (C:\BuildAgent10-1\work\e307a028e92341bb\Cinema.Web\UIAutomation\3_pageObjects\purchasePage.js:584:15)
    at Object. (C:\BuildAgent10-1\work\e307a028e92341bb\Cinema.Web\UIAutomation\2_testScenarios\purchaseFeature.js:663:30)
    at C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:94:23
    at new ManagedPromise (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1082:7)
    at controlFlowExecute (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:80:18)
    at TaskQueue.execute_ (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14)
    From: Task: Run it("click on "continue" button to confirm the payment") in control flow
    at Object. (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:79:14)
    at attemptAsync (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1916:24)
    at QueueRunner.run (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1871:9)
    at QueueRunner.execute (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1859:10)
    at Spec.Env.queueRunnerFactory (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:697:35)
    at Spec.execute (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:359:10)
    at Object.fn (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:2479:37)
    at attemptAsync (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1916:24)
    at QueueRunner.run (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1871:9)
    at C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:1898:16
    From asynchronous test:
    Error
    at Suite. (C:\BuildAgent10-1\work\e307a028e92341bb\Cinema.Web\UIAutomation\2_testScenarios\purchaseFeature.js:662:13)
    at addSpecsToSuite (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:833:25)
    at Env.describe (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:802:7)
    at jasmineInterface.describe (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:3375:18)
    at purchaseFeature (C:\BuildAgent10-1\work\e307a028e92341bb\Cinema.Web\UIAutomation\2_testScenarios\purchaseFeature.js:282:9)
    at Suite. (C:\BuildAgent10-1\work\e307a028e92341bb\Cinema.Web\UIAutomation\1_testLaunchers\desktopTestLauncher.js:32:21)
    at addSpecsToSuite (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:833:25)
    at Env.describe (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:802:7)
    at jasmineInterface.describe (C:\Users\teamcity_build\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:3375:18)
    ------- Stdout: -------
    [chrome #01-0] [31m× click on "continue" button to confirm the payment [39m (3 secs)
    [chrome #01-0] [31m- [39m [31mFailed: EADDRINUSE connect EADDRINUSE 127.0.0.1:60267 [39m
    [chrome #01-0]
    [chrome #01-0]

Most helpful comment

Read the Oracle advise (click here)

Adjusting TCP Settings for Heavy Load on Windows

The underlying Search architecture that directs searches across multiple physical partitions uses TCP/IP ports and non-blocking NIO SocketChannels to connect to the Search engines. These connections remain open in the TIME_WAIT state until the operating system times them out. Consequently, under heavy load conditions, the available ports on the machine running the Routing module can be exhausted.
On Windows platforms, the default timeout is 120 seconds, and the maximum number of ports is approximately 4,000, resulting in a maximum rate of 33 connections per second. If your index has four partitions, each search requires four ports, which provides a maximum query rate of 8.3 queries per second.
(maximum ports/timeout period)/number of partitions = maximum query rate.

If this rate is exceeded, you may see failures as the supply of TCP/IP ports is exhausted. Symptoms include drops in throughput and errors indicating failed network connections. You can diagnose this problem by observing the system while it is under load, using the netstat utility provided on most operating systems.

To avoid port exhaustion and support high connection rates, reduce the TIME_WAIT value and increase the port range.

Note: This problem does not usually appear on UNIX systems due to the higher default connection rate in those operating systems.

To set TcpTimedWaitDelay (TIME_WAIT):

Use the regedit command to access the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\TCPIP\Parameters registry subkey.

Create a new REG_DWORD value named TcpTimedWaitDelay.

Set the value to 60.

Stop and restart the system.

To set MaxUserPort (ephemeral port range):

Use the regedit command to access the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\TCPIP\Parameters registry subkey.

Create a new REG_DWORD value named MaxUserPort.

Set this value to 32768.

Stop and restart the system.

All 4 comments

Are you sure the port is not already used? See also https://stackoverflow.com/questions/4075287/node-express-eaddrinuse-address-already-in-use-kill-server

By the way, you are using an old version of Protractor and an old version of NodeJS, have you also tried updating?

See #4091

Read the Oracle advise (click here)

Adjusting TCP Settings for Heavy Load on Windows

The underlying Search architecture that directs searches across multiple physical partitions uses TCP/IP ports and non-blocking NIO SocketChannels to connect to the Search engines. These connections remain open in the TIME_WAIT state until the operating system times them out. Consequently, under heavy load conditions, the available ports on the machine running the Routing module can be exhausted.
On Windows platforms, the default timeout is 120 seconds, and the maximum number of ports is approximately 4,000, resulting in a maximum rate of 33 connections per second. If your index has four partitions, each search requires four ports, which provides a maximum query rate of 8.3 queries per second.
(maximum ports/timeout period)/number of partitions = maximum query rate.

If this rate is exceeded, you may see failures as the supply of TCP/IP ports is exhausted. Symptoms include drops in throughput and errors indicating failed network connections. You can diagnose this problem by observing the system while it is under load, using the netstat utility provided on most operating systems.

To avoid port exhaustion and support high connection rates, reduce the TIME_WAIT value and increase the port range.

Note: This problem does not usually appear on UNIX systems due to the higher default connection rate in those operating systems.

To set TcpTimedWaitDelay (TIME_WAIT):

Use the regedit command to access the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\TCPIP\Parameters registry subkey.

Create a new REG_DWORD value named TcpTimedWaitDelay.

Set the value to 60.

Stop and restart the system.

To set MaxUserPort (ephemeral port range):

Use the regedit command to access the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\TCPIP\Parameters registry subkey.

Create a new REG_DWORD value named MaxUserPort.

Set this value to 32768.

Stop and restart the system.

Read the Oracle advise (click here)

Adjusting TCP Settings for Heavy Load on Windows

The underlying Search architecture that directs searches across multiple physical partitions uses TCP/IP ports and non-blocking NIO SocketChannels to connect to the Search engines. These connections remain open in the TIME_WAIT state until the operating system times them out. Consequently, under heavy load conditions, the available ports on the machine running the Routing module can be exhausted.
On Windows platforms, the default timeout is 120 seconds, and the maximum number of ports is approximately 4,000, resulting in a maximum rate of 33 connections per second. If your index has four partitions, each search requires four ports, which provides a maximum query rate of 8.3 queries per second.
(maximum ports/timeout period)/number of partitions = maximum query rate.

If this rate is exceeded, you may see failures as the supply of TCP/IP ports is exhausted. Symptoms include drops in throughput and errors indicating failed network connections. You can diagnose this problem by observing the system while it is under load, using the netstat utility provided on most operating systems.

To avoid port exhaustion and support high connection rates, reduce the TIME_WAIT value and increase the port range.

Note: This problem does not usually appear on UNIX systems due to the higher default connection rate in those operating systems.

To set TcpTimedWaitDelay (TIME_WAIT):

Use the regedit command to access the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\TCPIP\Parameters registry subkey.

Create a new REG_DWORD value named TcpTimedWaitDelay.

Set the value to 60.

Stop and restart the system.

To set MaxUserPort (ephemeral port range):

Use the regedit command to access the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\TCPIP\Parameters registry subkey.

Create a new REG_DWORD value named MaxUserPort.

Set this value to 32768.

Stop and restart the system.

with me it didn't work

Was this page helpful?
0 / 5 - 0 ratings