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

try to find a free port if default already in use #283

Closed
wants to merge 1 commit into from
Closed

try to find a free port if default already in use #283

wants to merge 1 commit into from

Conversation

just-boris
Copy link

Now if specified port already is being used, plugin will throw an exception. It would be nice to be able try another port without extra bothering. Karma test runner already have this feature.

I often use your project when I have to test front end within java applications, and I wish to have this feature here as well. It will try to connect the default port, and if it is used, then try next port, and throw the error only if all of next 10 ports already busy.

@mprins
Copy link

mprins commented Sep 7, 2015

You might want to use InetSocketAddress with a portnumber of 0 to find a free ephemeral port.

eg.

int newPort = new java.net.InetSocketAddress(0).getPort();

@just-boris
Copy link
Author

Yes, I saw that behaviour.
But the main feature, which my logic gives, is a predictable used port range. Sometimes, (with a firewall, for example), you cannot connect to random port, but can setup trusted range (8234-8244 here by default).

Is there an another way to get free port from some given range?

@mprins
Copy link

mprins commented Sep 7, 2015

Is there an another way to get free port from some given range?
AFAIK no.

@klieber
Copy link
Collaborator

klieber commented Sep 16, 2020

This should be resolved in 3.0-beta-01. I decided to go with the simpler and more performant approach of just allowing the system to choose a random port if 8234 is not available. Seems to work nicely with the changes in #352 which automatically opens the browser and navigates to the spec runner for you.

klieber added a commit to klieber/jasmine-maven-plugin that referenced this pull request Aug 24, 2022
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

Successfully merging this pull request may close these issues.

3 participants