CppServer
CppServer copied to clipboard
[Question] Multiple SSLServer with a single Service
trafficstars
I would like to run two SSLServer instances (IPv4 and IPv6) in parallel.
My first plan was to start both in the same thread and run them with the same Asio::Service.
But when I do something like this:
asioService->Start();
sslServerIpv4->Start();
sslServerIpv6->Start();
while (shouldRun) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
serverIpv4->Stop();
serverIpv6->Stop();
asioService->Stop();
it crashes at serverIpv6->Stop(); with the assertion assert(IsStarted() && "SSL server is not started!"); failing.
Turns out, for the second server (serverIpv6) the auto start_handler = [this, self](){...} never gets called.
What else did I try:
- Increase the number of threads when creating the
Asio::Serviceand changing the pool option. - Create two threads and start a separate
Asio::ServiceandSSLServerin each.
All with the same result, that the second server wont start.
What do I need to change to allow multiple servers running at the same time?