Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

"Port 5858 is already in use" when using browser.pause more then once #2206

Closed
eolognt opened this issue Jun 4, 2015 · 24 comments
Closed

"Port 5858 is already in use" when using browser.pause more then once #2206

eolognt opened this issue Jun 4, 2015 · 24 comments

Comments

@eolognt
Copy link

eolognt commented Jun 4, 2015

I have the line browser.pause(); in a beforeEach-function in my Protractor spec and I thought it would act as a breakpoint for me to pause before every it and check out the browser before continuing with the command d to continue to the next debugger statement (which should be the beforeEach again). But when Protractor reach beforeEach for the second time I get the error:

Port 5858 is already in use. Please specify another port to debug.
[launcher] Process exited with error code 1

Isn't this how you're supposed to use the pause function? What's purpose of the d-command if you can't use browser.pause() multiple times in the code?

@gitjul
Copy link

gitjul commented Jun 10, 2015

Encountering the exact same issue.

@mribichich
Copy link

+1

@misbahkhan
Copy link

I'm not sure what the implications of this are, but you can specify the port as a param to browser.pause(). So something like

$('button').click();
browser.pause(5001);
$('#close').click();
browser.pause(5002);

would allow you to pause multiple times without crashing.

In which case, this would seem like expected behavior.

Maybe a bit more information in the documentation would help, but this feature is marked as beta/unstable so that makes sense.

@dtaylor-employii
Copy link

I am also experiencing this. I have tried both closing the debugger and continuing to the next debugger statement with the same result.

I think the hesitance to use the multiple ports is that this would appear to leave the ports open, so if you are running a long test suite, with multiple browser.pause, you would have a number of debug ports open. As well, the OPs issue is hitting the pause in the beforeEach, so this would require incrementing a debug variable after each pause to avoid the issue.

As a temporary workaround, I have put the following into our protractor.conf.js onPrepare function:

      global.debugPortNumber = 5000;
      global.initiateDebug = function() {
        browser.pause(debugPortNumber);
        debugPortNumber++;
      };

Then I can call initiateDebug() from wherever and not have to worry about manually updating the port number.

@nvega-ms
Copy link

nvega-ms commented Sep 7, 2015

Same issue here -> http://screencast.com/t/8CFTi1eGD0

@warreng
Copy link

warreng commented Nov 4, 2015

+1

@juliemr
Copy link
Member

juliemr commented Nov 18, 2015

I'm seeing this now even when running pause just once. @hankduan do you have time to take a look?

@SidBala
Copy link

SidBala commented Nov 19, 2015

+1 hitting same issue.

@martinsznapka
Copy link
Contributor

+1

@hankduan
Copy link
Contributor

hankduan commented Dec 4, 2015

Fixed here: #2763

@pellekrogholt
Copy link

@hankduan I tried out you #hack branch because I ran into the port problem.

I have a node project using

$ node --version
v5.2.0
$ npm --version
3.3.12

packages.json ->    
...
"protractor": "git@github.com:hankduan/protractor.git#hack",
"webdriver-manager": "^7.0.1",
"jasmine-core": "^2.3.4",
"karma": "0.13.8",
"karma-jasmine": "^0.3.5",

using you branch I run some e2e tests ~ (https://github.com/angular/protractor/blob/master/debugging/failure_spec.js)

$ ./node_modules/.bin/protractor debug protractor.conf.js 

raises:

Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Starting debugger agent.
Debugger listening on port 5858
debug> connecting to localhost:5858 ... ok
debug> break in timers.js:57
 55 };
 56 
>57 function listOnTimeout() {
 58   var msecs = this.msecs;
 59   var list = this;
debug> c
There was an internal error in Node's debugger. Please report this bug.
read EIO
cError: read EIO
    at exports._errnoException (util.js:856:11)
    at TTY.onread (net.js:545:26)

debug> debug> Segmentation fault (core dumped)

is this a nodejs or a protractor issue ?

if its a pure nodejs issue I have already added a comment to an existing issue nodejs/node-v0.x-archive#8030 (comment)

which node version do you / others use successfully for protractor debugging ?

@hankduan
Copy link
Contributor

That branch is for using Protractor with multiple browser.pause, not debug.
If all you did was add a debug to the commandline and did not touch the spec file, AND if the spec file runs without the debug property, then chances are it's a node issue, since it is controlled entirely by node.

And just as a background on what the debug command does, protractor simply calls node with --nodeDebug. See https://github.com/angular/protractor/blob/master/lib/cli.js

That being said, I have not been able to reproduce your issue (I've used 4.x and 5.0)

@pellekrogholt
Copy link

@hankduan ok I get the debugger thing and leaves to out for now.

I should have made it more clear that I also have an e2e test with multiple browser.pause() along the failure_spec.js:

describe('portal', function() {
    it('must provide login', function() {
        browser.get('http://localhost:3000');

        browser.pause();

        element(by.model('email')).sendKeys('an-email');
        element(by.model('password')).sendKeys('a-password');
        var selector = by.cssContainingText('a,button', 'Sign in');
        var button = browser.findElement(selector);
        button.click();

        browser.pause();

        expect(element.all(by.css('.search-inner')).count()).toEqual(1);
    });
});

now I downgrade to node 5.0.0

and look up port 5858 usage

$ netstat -ant | grep 5858
// empty

and use your protractor branch. now I get 'the port already in use' error:

$ ./node_modules/.bin/protractor debug protractor.conf.js
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Starting debugger agent.
Debugger listening on port 5858
debug> connecting to localhost:5858 ... ok
debug> break in timers.js:56
 54 };
 55 
>56 function listOnTimeout() {
 57   var msecs = this.msecs;
 58   var list = this;
debug>
debug> debug> Started
Port 5858 is already in use. Please specify another port to debug.
[launcher] Process exited with error code 1

any hints further suggestions ?

I naively tried with one pause only:

browser.pause(5860);

ran the test again

$ ./node_modules/.bin/protractor debug protractor.conf.js
...
Encountered browser.pause(). Attaching debugger...

------- WebDriver Debugger -------
Starting WebDriver debugger in a child process. Pause is still beta, please report issues at github.com/angular/protractor

press c to continue to the next webdriver command
press ^D to detach debugger and resume code execution
type "repl" to enter interactive mode
type "exit" to break out of interactive mode

(node) warning: possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at Client.addListener (events.js:239:17)
    at Client.Readable.on (_stream_readable.js:665:33)
    at connectWithRetry (/project/node_modules/protractor/lib/debugger/debuggerCommons.js:33:10)
    at null._onTimeout (/project/node_modules/protractor/lib/debugger/debuggerCommons.js:38:15)
    at Timer.listOnTimeout (timers.js:92:15)
/project/node_modules/protractor/lib/debugger/debuggerCommons.js:35
            throw e;
            ^

Error: connect EALREADY 127.0.0.1:5860 - Local (127.0.0.1:56184)
    at Object.exports._errnoException (util.js:860:11)
    at exports._exceptionWithHostPort (util.js:883:20)
    at connect (net.js:841:14)
    at net.js:984:7
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:63:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:82:10)

but I running out of ideas how to solve it...

@hankduan
Copy link
Contributor

Run it as ./node_modules/.bin/protractor protractor.conf.js, not ./node_modules/.bin/protractor debug protractor.conf.js. Let me know if that fixes your problem.

@pellekrogholt
Copy link

@hankduan thank you for the patience without the debug param the browser.pause() works.

@juliemr
Copy link
Member

juliemr commented Feb 9, 2016

This is out in the 3.1.0 release!

@juliemr juliemr closed this as completed Feb 9, 2016
@rkayaith
Copy link

rkayaith commented Jun 27, 2016

This seems to be happening again on 3.3.0. I tried 3.2.0 and 3.1.0 and it works on both.

Error:

P:\test>node node_modules\protractor\bin\protractor conf.js
...
wd-debug> Resuming code execution
Port 5858 is already in use. Please specify another port to debug.
[15:20:45] E/launcher - Process exited with error code 1

Same thing happens when I use protractor conf.js (global install is also v3.3.0)

Test files:

// conf.js
exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['spec.js']
}

// spec.js
describe('Protractor Demo App', function() {
  it('should have a title', function() {
    browser.pause();
    browser.get('http://juliemr.github.io/protractor-demo/');
    browser.pause();
    expect(browser.getTitle()).toEqual('Super Calculator');
  });
});

@robertye112
Copy link

+1 this is happening to me in version 3.3.0. (this never used to happen, I know how to use these pause/debug features, it's specific to 3.3.0)

@tommyz0123
Copy link

+1 4.0.4 happening as well

@heathkit
Copy link
Contributor

I fixed this issue in 4.0.5

#3504

On Sep 28, 2016 22:16, "tommyz0123" notifications@github.com wrote:

+1 4.0.4 happening as well


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#2206 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAlRwySpsrbPFeitr7ibMP6G53OIYfWks5qutk6gaJpZM4E4T-U
.

@isian8814
Copy link

+1
It still happened in 4.0.11

@bvasilchik
Copy link

+1
Yeah I thought maybe I did something wrong by using browser.pause more than once. I got the same error and thought it was odd. B/c essentially it's like a breakpoint and I wanted to step to the next breakpoint

@heathkit
Copy link
Contributor

Sorry, I'm able to repro the problem in 4.0.11. It's working for me, but maybe my test case is too simple. If you're still seeing duplicate port errors, could you open a new issue with some more details? For example, is the error consistent or intermittent? Do you see it with browser.pause() in different it() blocks? A repro example is always really helpful when debugging issues like this.

Also, if you happen to have multiple Protractor instances doing browser.pause(), you'll see this error. That's a known issue, and we can fix it if it's a problem for people.

@kemerydev
Copy link

kemerydev commented Oct 7, 2017

Fixed easily enough in osx or linux by killing the protractor process that is taking the port. In a terminal window, "ps -A | grep protractor" will show the running process which is consuming the port, and the problem will be solved with "kill -s kill (pid)" where (pid) is the number of the listed process from the previous command

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