mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
fix: Fix bugs in new webserver (#1780)
Fixes #919. Fixes bugs for new webserver: - Unhandled exception when closing already closed websocket - No pings for plain websocket connection - Server drops websocket connection when client responds to pings but doesn't send anything Also changing API of ng connections. Now timeout is set by a separate method instead of providing it for each call.
This commit is contained in:
@@ -223,6 +223,7 @@ Server::onWs(MessageHandler handler)
|
||||
std::optional<std::string>
|
||||
Server::run()
|
||||
{
|
||||
LOG(log_.info()) << "Starting ng::Server";
|
||||
auto acceptor = makeAcceptor(ctx_.get(), endpoint_);
|
||||
if (not acceptor.has_value())
|
||||
return std::move(acceptor).error();
|
||||
@@ -236,6 +237,7 @@ Server::run()
|
||||
boost::asio::ip::tcp::socket socket{ctx_.get().get_executor()};
|
||||
|
||||
acceptor.async_accept(socket, yield[errorCode]);
|
||||
LOG(log_.trace()) << "Accepted a new connection";
|
||||
if (errorCode) {
|
||||
LOG(log_.debug()) << "Error accepting a connection: " << errorCode.what();
|
||||
continue;
|
||||
@@ -290,6 +292,7 @@ Server::handleConnection(boost::asio::ip::tcp::socket socket, boost::asio::yield
|
||||
}
|
||||
return;
|
||||
}
|
||||
LOG(log_.trace()) << connectionExpected.value()->tag() << "Connection created";
|
||||
|
||||
boost::asio::spawn(
|
||||
ctx_.get(),
|
||||
|
||||
Reference in New Issue
Block a user