Regarding the solution for dynamically adding listening ports.
"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?"
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
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. 😭
Kestrel can add ports via config without restarting.
Perfect, I have resolved the issue perfectly.
Closing as answered, let us know if we've missed anything.