Skip to content

Commit 4348b55

Browse files
v1.0.19: align read msg limit with native protocol
1 parent f5da64e commit 4348b55

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.24)
22

3-
project(native_streaming VERSION 1.0.18 LANGUAGES CXX)
3+
project(native_streaming VERSION 1.0.19 LANGUAGES CXX)
44

55
if (NOT CMAKE_MESSAGE_CONTEXT)
66
set(CMAKE_MESSAGE_CONTEXT ${PROJECT_NAME})

src/client.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ void Client::onResolve(const boost::system::error_code& ec, boost::asio::ip::tcp
8989

9090
websocketStream = std::make_shared<WebsocketStream>(*ioContextPtr);
9191
websocketStream->write_buffer_bytes(65536);
92+
// 256 MB - one byte bigger than max payload size within native transport protocol used above websocket connection
93+
websocketStream->read_message_max(0x10000000);
94+
9295
boost::beast::get_lowest_layer(*websocketStream).async_connect(
9396
results,
9497
[this, weak_self = weak_from_this(), wsStream = websocketStream](
@@ -170,6 +173,11 @@ void Client::onUpgradeConnection(const boost::system::error_code& ec, std::share
170173
return;
171174
}
172175

176+
NS_LOG_D("Websocket connection: auto-fragment {}, max read masg {}, write buffer size {}",
177+
wsStream->auto_fragment(),
178+
wsStream->read_message_max(),
179+
wsStream->write_buffer_bytes());
180+
173181
onNewSessionCallback(createSession(wsStream, endpointAddress, endpointPortNumber));
174182
}
175183

src/server.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ void Server::onAcceptTcpConnection(boost::asio::ip::tcp::acceptor& tcpAcceptor,
136136

137137
auto wsStream = std::make_shared<WebsocketStream>(std::move(socket));
138138
wsStream->write_buffer_bytes(65536);
139+
// 256 MB - one byte bigger than max payload size within native transport protocol used above websocket connection
140+
wsStream->read_message_max(0x10000000);
139141

140142
boost::beast::http::async_read(wsStream->next_layer(),
141143
acceptBuffer,
@@ -235,6 +237,12 @@ void Server::onUpgradeConnection(const boost::system::error_code& ec,
235237
}
236238

237239
NS_LOG_I("Client {} - websocket connection accepted", endpointAddress);
240+
241+
NS_LOG_D("Websocket connection: auto-fragment {}, max read masg {}, write buffer size {}",
242+
wsStream->auto_fragment(),
243+
wsStream->read_message_max(),
244+
wsStream->write_buffer_bytes());
245+
238246
onNewSessionCallback(createSession(wsStream, userContext, endpointAddress, endpointPortNumber));
239247
}
240248

0 commit comments

Comments
 (0)