Upcoming Feature: Payara Micro HTTP & HTTPS auto-binding
Originally published on 17 Jul 2015
Last updated on 05 Apr 2016
Taking inspiration from the way the integrated Hazelcast automatically searches for an open port when clustering, I decided to add in a similar feature for Payara Micro when trying to bind its HTTP and HTTPS ports.
In the upcoming Payara 4.1.153 release, Payara Micro will be shipping with support for the first working iteration of this new feature. To help and keep Payara as a drop-in replacement for GlassFish though, the auto-binding is not enabled by default, and is instead enabled by passing in an extra option when starting Payara Micro.
The three new Payara Micro options pertaining to this feature are:
It’s super easy to use, you just have to set the respective auto-bind option to true for the HTTP and/or SSL port:
To grant some control over how the auto-bind feature works, I created the --autoBindRange option. This option allows you to determine how many ports to attempt binding to before giving up. This option defaults to 5 if not specified.As an example:
This will have Payara Micro attempt to find a free port on port 8080, then 8081, 8082, and 8083 before giving up and failing to start.In its current form, the auto-bind feature assumes that the default port is 8080 for HTTP, and 8181 for SSL; the feature will not release with the capability of reading values set in a domain.xml file. Having the auto-bind feature read the HTTP and HTTPS port values from a domain.xml is something we’ll be looking at for a future release.If you want to check out the source code for this, check out the pull request here: https://github.com/payara/Payara/pull/359/filesIf you have any ideas for how to improve this, or any other feature in Payara, please consider raising an issue on our GitHub project page!
In the upcoming Payara 4.1.153 release, Payara Micro will be shipping with support for the first working iteration of this new feature. To help and keep Payara as a drop-in replacement for GlassFish though, the auto-binding is not enabled by default, and is instead enabled by passing in an extra option when starting Payara Micro.
The three new Payara Micro options pertaining to this feature are:
- --autoBindHttp – Enables auto-bind functionality for the HTTP port
- --autoBindSsl – Enables auto-bind functionality for the HTTPS port
- --autoBindRange – Sets the range for the auto-bind feature
It’s super easy to use, you just have to set the respective auto-bind option to true for the HTTP and/or SSL port:
java -jar payara-micro.jar --autoBindHttp
java -jar payara-micro.jar --port 8080 --autoBindHttp --autoBindRange 3
Related Posts
The Payara Monthly Catch - October 2024
Published on 30 Oct 2024
by Chiara Civardi
0 Comments
Can You Futureproof Your Enterprise Java Apps or Are They Doomed to Fall Behind?
Published on 16 Oct 2024
by Chiara Civardi
0 Comments