From 4348b55093e0cccaa2b716397a44288db47aad4e Mon Sep 17 00:00:00 2001 From: Nikolai Shipilov Date: Wed, 15 Oct 2025 14:51:05 +0200 Subject: [PATCH] v1.0.19: align read msg limit with native protocol --- CMakeLists.txt | 2 +- src/client.cpp | 8 ++++++++ src/server.cpp | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dc4bb2..fba5a11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.24) -project(native_streaming VERSION 1.0.18 LANGUAGES CXX) +project(native_streaming VERSION 1.0.19 LANGUAGES CXX) if (NOT CMAKE_MESSAGE_CONTEXT) set(CMAKE_MESSAGE_CONTEXT ${PROJECT_NAME}) diff --git a/src/client.cpp b/src/client.cpp index 441f83f..7fa371b 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -89,6 +89,9 @@ void Client::onResolve(const boost::system::error_code& ec, boost::asio::ip::tcp websocketStream = std::make_shared(*ioContextPtr); websocketStream->write_buffer_bytes(65536); + // 256 MB - one byte bigger than max payload size within native transport protocol used above websocket connection + websocketStream->read_message_max(0x10000000); + boost::beast::get_lowest_layer(*websocketStream).async_connect( results, [this, weak_self = weak_from_this(), wsStream = websocketStream]( @@ -170,6 +173,11 @@ void Client::onUpgradeConnection(const boost::system::error_code& ec, std::share return; } + NS_LOG_D("Websocket connection: auto-fragment {}, max read masg {}, write buffer size {}", + wsStream->auto_fragment(), + wsStream->read_message_max(), + wsStream->write_buffer_bytes()); + onNewSessionCallback(createSession(wsStream, endpointAddress, endpointPortNumber)); } diff --git a/src/server.cpp b/src/server.cpp index a41705d..e4bd1d9 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -136,6 +136,8 @@ void Server::onAcceptTcpConnection(boost::asio::ip::tcp::acceptor& tcpAcceptor, auto wsStream = std::make_shared(std::move(socket)); wsStream->write_buffer_bytes(65536); + // 256 MB - one byte bigger than max payload size within native transport protocol used above websocket connection + wsStream->read_message_max(0x10000000); boost::beast::http::async_read(wsStream->next_layer(), acceptBuffer, @@ -235,6 +237,12 @@ void Server::onUpgradeConnection(const boost::system::error_code& ec, } NS_LOG_I("Client {} - websocket connection accepted", endpointAddress); + + NS_LOG_D("Websocket connection: auto-fragment {}, max read masg {}, write buffer size {}", + wsStream->auto_fragment(), + wsStream->read_message_max(), + wsStream->write_buffer_bytes()); + onNewSessionCallback(createSession(wsStream, userContext, endpointAddress, endpointPortNumber)); }