[undertow-dev] start listener on random port

Friso van Vollenhoven f.van.vollenhoven at gmail.com
Thu Dec 1 01:09:21 EST 2016


Hi,
For what it's worth, we had the same issue. We worked around it by opening
a server socket ourselves, check the port that it grabbed and immediately
closing the socket and then assign that port to Undertow. This is very
unlikely to go into a race, as the kernel always assigns incrementing port
numbers. It's a bit of a hack, but works for us.

Friso

On Wed, Nov 30, 2016 at 10:24 PM, Stuart Douglas <sdouglas at redhat.com>
wrote:

> We don't support this at the moment, but it would be something that is
> nice to have.
>
> Stuart
>
> On Wed, Nov 30, 2016 at 12:03 AM, Sascha Sadat-Guscheh <kid at bitkid.com>
> wrote:
> > hello undertow developers!
> >
> > is there a way to start a http listener on a random free port? i have a
> test suite that runs multithreaded so each untertow server uses a random
> port, that i get like this:
> >
> > new ServerSocket(0).getLocalPort()
> >
> > sometimes i run into a race condition when a different process grabs the
> port before undertow listens on it.  so a possible solution would be to
> just let undertow assign the port, and then ask it what port its listening
> on. (or pass the socket instead of the port number to undertow)
> >
> > is that a worthwile feature? should i try to submit a pr that does that?
> or is it already possible?
> >
> > thanks!
> >
> > _______________________________________________
> > undertow-dev mailing list
> > undertow-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/undertow-dev
>
> _______________________________________________
> undertow-dev mailing list
> undertow-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/undertow-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20161201/669aefe9/attachment.html 


More information about the undertow-dev mailing list