Closed vietj closed 8 years ago
I'm not sure that makes sense.
actualPort is for the case of finding out the port if you asked the server to listen on port 0 which means "choose a random port".
But I don't think you'd do that for an http server as they'd almost always need to be on a well known port (e.g. 80, or 8080) for a client to connect.
that’s rather for testing purposes.
at the end nothing prevents using port 0 with http server, so I don’t see why the actual port could not be known after listen.
On Feb 29, 2016, at 4:37 PM, Tim Fox notifications@github.com wrote:
I'm not sure that makes sense.
actualPort is for the case of finding out the port if you asked the server to listen on port 0 which means "choose a random port".
But I don't think you'd do that for an http server as they'd almost always need to be on a well known port (e.g. 80, or 8080) for a client to connect.
— Reply to this email directly or view it on GitHub https://github.com/eclipse/vert.x/issues/1318#issuecomment-190259680.
I can see it might be useful for testing, but in the "real-world" I think it would be extremely unusual to start an http server listening on a random port.
It is extremely useful with testing scenario. I have a tough time battling with already used port problem when running tests.
I would concur with @testn this is very useful for testing. I saw the documentation for NetServer and was surprised to find that the same method did not exist for HttpServer.
Don't only think of the edge service case, such as a web server serving edge traffic (html).
You cannot always know which port your http server will listen to, especially, if it scheduled dynamically to run someplace, and it uses service discovery to make itself available to other services/servers, i.e. your vertx server is a service running with a set of other services.
NetServer has an
actualPort()
that returns the current actual port, there could be the same for HttpServer