0

I want to run multiple, non-clustered verticles on my webserver. Each verticle is started by a separate process/commandline and creates his own HTTP server (vertx.createHttpServer) for the same host and the same port with unique routes. However, this does not seem to work because after starting one verticle, all further verticles throw a BindException "Address already in use".

As a Vert.x novice I can only think of two ways to get passed this:

  1. Programmatically deploy all verticles from a single process, and make all verticles use a global router instance for adding their specific routes.
  2. Cluster the verticles and create an additional verticle that provides a webserver which allows to setup routes and handle requests and response via the clustered eventbus.

Both approaches would force me to rewrite large parts of my verticles.

Is there another way to circumvent this multiserver issue?

xpages-noob
  • 1,569
  • 1
  • 10
  • 37

1 Answers1

1

Each verticle is started by a separate process/commandline and creates his own HTTP server (vertx.createHttpServer) for the same host and the same port

TCP connections only allow a single process to listen on the same port on the same host. There are some ways around this (see the responses to this question), but I'm not sure doing so is the best solution.

... for the same host and the same port with unique routes

Vertx-Web provides many ways to route requests. One such method I've used recently is a sub-router, which may be a viable solution for you. You can configure a "main" router to route requests to a different router for each the "unique routes" you want.

MitchAman
  • 116
  • 5
  • The `SO_REUSEADDR` socket option would only work if your processes were serving the same requests. The kernel will load balance new TCP connections among the listening processes and has no knowledge of your routing needs. – tsegismont Sep 12 '18 at 10:29