Crow
Crow copied to clipboard
Websocket: Message is not send when closing connection
When I test the following code:
CROW_WEBSOCKET_ROUTE(crowApp, "/test")
.onopen([&](crow::websocket::connection &conn) {
conn.send_text("Error with query params");
conn.close("error", crow::websocket::PolicyViolated);
})
.onclose([&](crow::websocket::connection &conn, const std::string &reason, uint16_t code) {
// This gets called twice?
})
I never get the Error with query params message.
Can you write a PR containing a test for this?
possibly a bug, i am not a websockets expert, but code uses asio::post for send_text and asio::dispatch for close, so maybe it overrides and closes before the text is send.
This was not fixed by https://github.com/CrowCpp/Crow/pull/1101, please reopen.