reverse-proxy icon indicating copy to clipboard operation
reverse-proxy copied to clipboard

Regarding the solution for dynamically adding listening ports.

Open shumtn opened this issue 1 year ago • 5 comments

"Unfortunately, it is not possible to dynamically add listening ports. Are there any other good solutions, such as multi-process? However, this would still cause client connections to be disconnected, such as WebSocket. Currently, I can't think of a good solution. Do you have any good ideas?"

shumtn avatar Dec 30 '24 02:12 shumtn

There are some less obvious ways of doing this.

Kestrel supports dynamic port changes via config. To change them programmatically you can use an in-memory config provider.

HttpSys supports programmatic dynamic port changes. https://github.com/dotnet/aspnetcore/blob/f7ff82f6674ae31c638d82aab86604b94b88766b/src/Servers/HttpSys/samples/HotAddSample/Startup.cs#L21-L46

Tratcher avatar Dec 31 '24 16:12 Tratcher

I mean dynamically adding reverse proxy ports similar to nginx -s reload without disconnecting the proxy websocket connection. I looked into Kestrel, but it seems there is no good way to do this without restarting the program, which would cause the websocket connection to be disconnected. 😭

shumtn avatar Jan 01 '25 03:01 shumtn

Kestrel can add ports via config without restarting.

Tratcher avatar Jan 01 '25 19:01 Tratcher

Perfect, I have resolved the issue perfectly.

shumtn avatar Jan 04 '25 03:01 shumtn

Closing as answered, let us know if we've missed anything.

MihaZupan avatar Jan 08 '25 17:01 MihaZupan