Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Random port not reported correctly by webserver module #14925

Closed
wcummings opened this issue Mar 29, 2017 · 0 comments
Closed

Random port not reported correctly by webserver module #14925

wcummings opened this issue Mar 29, 2017 · 0 comments

Comments

@wcummings
Copy link

wcummings commented Mar 29, 2017

  1. What version?
    2.1.1

  2. What steps will reproduce the problem?

    1. Get a copy of https://github.com/numtel/phantomjs-persistent-server/blob/master/src/phantom-server.js
    2. Change the last line to console.log(server.port, 'Ready.');
    3. Run it passing 0 (random port), and see that server.port returns 0 and not the port its bound to.
  3. Which operating system are you using?
    Linux

  4. Did you use binary PhantomJS or did you compile it from source?
    Binary

  5. Please provide any additional information below.

I wrote a patch I'm currently fashioning into a PR, which will reference this issue as requested in the CONTRIBUTING file.

Assigning a random port comes in handy if you're managing a bunch of phantom instances on one machine. Using 0 is the only race-condition-proof way of assigning a random port, as far as I know.

Here's a case where someone is working around the issue in a pretty heinous way that I didn't want to duplicate in my project:

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

No branches or pull requests

1 participant