I'm using boost-beast websocket of the following type:
boost::beast::websocket::stream<
boost::beast::ssl_stream<boost::beast::tcp_stream>> ws_;
while trying to send messages using this ws_, I always get empty error_code, even when network is down:
boost::asio::spawn(io_context_, [&](const boost::asio::yield_context &yield) {
boost::beast::error_code ec;
ws_.async_write(boost::asio::buffer(bodyJson.dump()), yield[ec]);
--> if (ec) {
log("fail");
}
});
Using debugger, if I print the error_code (ec) after async_write when the network is down, I get
(lldb) p ec.message()
(std::string) $9 = "Undefined error: 0"
(lldb) p ec.to_string()
(std::string) $10 = "system:0"
(lldb) p ec.value()
(int) $11 = 0
(lldb) p ec.category()
(const boost::system::error_category) $12 = {
id_ = 12874403176081448913
ps_ = {
Value = nullptr
}
}
shouldn't I get some sort of meaningful error where the connection is unreachable due to network shutdown ?
thanks