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

Using random port with HttpServer only works for first server. #1596

Closed
dgalligan opened this issue Aug 31, 2016 · 2 comments
Closed

Using random port with HttpServer only works for first server. #1596

dgalligan opened this issue Aug 31, 2016 · 2 comments

Comments

@dgalligan
Copy link

dgalligan commented Aug 31, 2016

I am trying to setup multiple HttpServer instances listening on different random ports in my application using the port 0 method. The first one works, however subsequent ones do not and the actualPort() method reports 0. The same technique used with NetServer works as expected with each instance reporting a random port in actualPort();

Using Clement's excellent starter app to reproduce. Change the start method to

  @Override
  public void start() {
    vertx.createHttpServer()
        .requestHandler(req -> req.response().end("Hello Vert.x!"))
        .listen(0, res -> System.out.println("Http Port " + res.result().actualPort()));
    vertx.createHttpServer()
        .requestHandler(req -> req.response().end("Hello Vert.x!"))
        .listen(0, res -> System.out.println("Http Port " + res.result().actualPort()));
    vertx.createNetServer()
        .connectHandler(req -> {})
        .listen(0, res -> System.out.println("Net Port " + res.result().actualPort()));
    vertx.createNetServer()
        .connectHandler(req -> {})
        .listen(0, res -> System.out.println("Net Port " + res.result().actualPort()));
}

Output

Aug 30, 2016 11:08:23 PM io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer
INFO: Succeeded in deploying verticle
Http Port 52550
Http Port 0
Net Port 52551
Net Port 52552
@vietj
Copy link
Member

vietj commented Aug 31, 2016

thanks for reporting, will have a look

@snazy
Copy link

snazy commented Mar 21, 2024

@vietj we've seen that Quarkus (even on latest 'main' with Vert.x 4.5.5) still bound both HTTP servers (the "main" one and the one for management endpoints) to the same port, when both HTTP servers were configured with port=0. Not sure whether this issue was meant to fix the same issue or not - so just a heads-up.

Strike that. I didn't look at the creation date of this issue. Sorry for the noise.

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

No branches or pull requests

3 participants