websocketserver: Retry listen on IPv4 if IPv6 is not available

Fixes #1311
This commit is contained in:
tt2468 2023-05-27 22:54:02 -07:00
parent ac00465565
commit 6434c42155

View File

@ -113,6 +113,10 @@ void WebSocketServer::Start()
} else {
blog(LOG_INFO, "[WebSocketServer::Start] Not locked to IPv4 bindings");
_server.listen(conf->ServerPort, errorCode);
if (errorCode && errorCode == websocketpp::lib::asio::error::address_family_not_supported) {
blog(LOG_INFO, "[WebSocketServer::Start] IPv6 address family not supported, binding only to IPv4");
_server.listen(websocketpp::lib::asio::ip::tcp::v4(), conf->ServerPort, errorCode);
}
}
if (errorCode) {