Project

General

Profile

Wt::WServer::httpPort() and dedicated process

Added by Marcelo Antunes about 1 month ago

I'm running my wt app with wthttp and on a dedicated process mode.
And the function Wt::WServer::instance()->httpPort(), returns a random port (probably is the port used for inter process communication)

Besides correcting that, i have another suggestion:
Should create a function Wt::WServer::instance()->httpsPort(), to return the https port, when the application have it.

Regards
Marcelo


Replies (3)

RE: Wt::WServer::httpPort() and dedicated process - Added by Matthias Van Ceulebroeck 17 days ago

Hey Marcelo,

I believe you are running into expected behavior. When you run a WServer with a dedicated sessions configured only a single instance will be launched that listens to the actual configured port (e.g. 80 for HTTP). This will then server as a controller for all connections.
Each connection/session will spawn a new WServer, and WApplication. Calling httpPort() on either of them will indeed result in a "random" port. The port with which the newly spawn instances communicate with the main WServer.

The httpPort() function will return the port(s) its listening to. If the server is set to listen to HTTPS, the HTTPS port will be returned, otherwise the HTTP port. It will only return the first port it listens to.
The function thus combines the two.

I suppose we could have a httpsPort() function in case that Wt is build with SSL support. I cannot simply remove the HTTPS ports from the function though, for backwards compatibility.
It can be tracked with ticket: #13294.

RE: Wt::WServer::httpPort() and dedicated process - Added by Marcelo Antunes 16 days ago

Would be great if the httpport() method returns the "real" port, the one that is used by controller.

Regards

RE: Wt::WServer::httpPort() and dedicated process - Added by Matthias Van Ceulebroeck 15 days ago

It should, if you are asking the main server, not any of the applications spawned in dedicated mode.
Additionally, since it is a separate process it makes more sense to display the port that process is listening to for its communication, I think. Since the port is ONLY bound to the main server. No other process actually listens to that port.

If you do want to find out the "main" port, you can always use a tool like ps or pstree, or read from your configuration.

I will give the consistency some thought though.

    (1-3/3)