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

Spring boot server port range support #9403

Closed
wants to merge 3 commits into from

Conversation

ishara
Copy link

@ishara ishara commented Jun 4, 2017

if server.port value is set to 0, the server port will automatically assigned.
If we need to restrict automatic port to specific range value such as 8000-9000, the new setting server.port-range feature added.

Please check
Thank you

@pivotal-issuemaster
Copy link

@ishara Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 4, 2017
@pivotal-issuemaster
Copy link

@ishara Thank you for signing the Contributor License Agreement!

@ishara ishara closed this Jun 4, 2017
@ishara ishara reopened this Jun 4, 2017
@wilkinsona
Copy link
Member

Thanks for opening your first Spring Boot pull request.

I see that you've used SocketUtils.findAvailableTcpPort to find a free port. Our experience of using it in our own tests is that it's too flakey to use in main code. To consider merging this I think we'd need to use an alternative and, unfortunately, I don't know of a good one. Perhaps you do though?

@wilkinsona wilkinsona added status: on-hold We can't start working on this issue yet status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 4, 2017
@ishara
Copy link
Author

ishara commented Jun 5, 2017

This is can not avoid, but if we can retry with until success with another port, seems acceptably.
I have just check the code, If we can get the control of port binding for all org.springframework.boot.web.server.WebServer implementation, this can achieve.

@philwebb
Copy link
Member

philwebb commented Jun 6, 2017

Unfortunately the issue we generally find with SocketUtils.findAvailableTcpPort isn't that it fails, but rather it thinks it has succeeded but in reality the port is not available. Adding a retry is unlikely so solve that issue I'm afraid.

The way that SocketUtils.findAvailableTcpPort works is that it first finds a free port and then it releases it so that it can be used by the real server. After the release happens the OS assumes it's free to dish it out again, so it can be used before the real server actually gets a chance to start.

The only way I can think of to support this would be to dig into the internals of Tomcat/Undertow/Jetty to see if it's possible to obtain and keep the server port directly.

@philwebb
Copy link
Member

philwebb commented Jun 6, 2017

Thanks for the PR, but I think unfortunately we'll need to decline this in its current form for the above reasons. If you manage to find an alternative way to obtain the port please do open a new pull request.

Thanks again!

@philwebb philwebb closed this Jun 6, 2017
@philwebb philwebb added status: declined A suggestion or change that we don't feel we should currently apply and removed status: on-hold We can't start working on this issue yet status: waiting-for-feedback We need additional information before we can continue labels Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants