#1 2026-03-26 06:35:28

mormot.coremy_only_lonely
Member
Registered: 2024-12-09
Posts: 14

Binding multiple ports to multiple routes

I'm using THttpApiServer to achieve this goal in the past, which works great.
But now I'm tring to port the application to Linux, so THttpApiServer is no longer an option.
Do I have to create multiple THttpServer instance to achieve the same goal?

Offline

#2 2026-03-26 15:21:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,552
Website

Re: Binding multiple ports to multiple routes

Can you explain a little bit more?

Offline

#3 2026-03-27 16:32:12

mormot.coremy_only_lonely
Member
Registered: 2024-12-09
Posts: 14

Re: Binding multiple ports to multiple routes

ab wrote:

Can you explain a little bit more?

Sure.

When I use THttpApiServer, I can add multiple routes with different ports using AddUrl.

For example:

AddUrl('test1','8056')
AddUrl('test2','8097')

But when I am using THTTPServer, it seems I can only pass the port parameter to the constructor, it does not support to bind different routes to different ports.

Offline

#4 2026-07-06 15:06:56

mormot.coremy_only_lonely
Member
Registered: 2024-12-09
Posts: 14

Re: Binding multiple ports to multiple routes

If I need to use an async handle to reponse the request, it seems my only option is to setup an Nginx server as a reverse proxy, as I cannot setup multiple HTTP server to handle the logic as the non-async version could do.
@ab: Is it possible this could be supported?

Last edited by mormot.coremy_only_lonely (2026-07-06 15:26:21)

Offline

#5 2026-07-07 06:27:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,552
Website

Re: Binding multiple ports to multiple routes

So you want a single THttpApiServer, but several ports?

Just one question: why several ports?

Offline

#6 2026-07-13 14:25:39

mormot.coremy_only_lonely
Member
Registered: 2024-12-09
Posts: 14

Re: Binding multiple ports to multiple routes

ab wrote:

So you want a single THttpApiServer, but several ports?

Just one question: why several ports?

No, to be exact, different ports for different paths in THttpAsyncServer.

My use case: It is served as an HTTP server that receives requests from various SDK servers. Some SDKs require that the URL must be the root path, which is beyond my control. Currently, I use THTTPAPIServer, which works quite well for this scenario. However, I want to migrate to the new asynchronous HTTP server.

Each SDK's individual network traffic is not very large, but when added together, it becomes substantial. I do not want to create multiple THTTPServer instances for every single SDK, as that might create many threads that I do not need.

It is a common feature that supported by Nginx or IIS.

Last edited by mormot.coremy_only_lonely (2026-07-13 14:37:46)

Offline

Board footer

Powered by FluxBB