Crow
Crow copied to clipboard
Crow continues to LISTEN on the port after calling `stop` method
Please, consider the following issue:
Version: current master @ 4f3f5deaaa01825c63c83431bfa96ccec195f741 ASIO version 1.24.0 (Boost not installed)
#include <crow.h>
#include <iostream>
#include <thread>
int main()
{
crow::SimpleApp app;
CROW_ROUTE(app, "/do")([&]() {
return crow::response(200);
});
std::thread t([&](){
app.port(9091).concurrency(1).run();
});
app.wait_for_server_start();
app.stop();
if (t.joinable())
t.join();
std::this_thread::sleep_for(std::chrono::seconds(600));
return 0;
}
During the 600 seconds pause, the server is still listening on the port 9091.
The same happens using run_async.
netstat -tulpn | grep 9091
tcp 0 0 0.0.0.0:9091 0.0.0.0:* LISTEN
Output log in debug mode:
(2023-10-25 14:26:58) [INFO ] Crow/master server is running at http://0.0.0.0:9091 using 2 threads
(2023-10-25 14:26:58) [INFO ] Call `app.loglevel(crow::LogLevel::Warning)` to hide Info level logs.
(2023-10-25 14:26:58) [INFO ] Closing IO service 0x7fac78001a60
(2023-10-25 14:26:58) [INFO ] Closing main IO service (0x7fac78001020)
(2023-10-25 14:26:58) [INFO ] Exiting.
Maybe explanation is here: https://stackoverflow.com/questions/11191028/boostasio-how-to-interrupt-a-blocked-tcp-server-thread
I have similar problem. I have process with run crow on some port. When I want to restart process, I call app.stop() wait for joining thread and restart current process and process on start again init crow on same port. And when I try sending request I have infinite reply. I guess the problem is because I restart on same port and connection internally didnt stop. Looking for fix