From 90e37ae40bc80c99d1fae6078a6843a7e1d8f067 Mon Sep 17 00:00:00 2001 From: oerol <74826613+oerol@users.noreply.github.com> Date: Mon, 25 Apr 2022 14:08:59 +0200 Subject: [PATCH] return statement to exit reading loop Merges PR#2414 I used this example to start building my WebSocket application, however, I noticed that upon removing the echoing in the on_read method, the server repeatedly throws errors without exiting the method. You can recreate this problem by replacing the async_write with do_write and cause any error (i.e. client reloads the page). Adding a return statement here would make debugging for future changes much easier and it wouldn't harm the existing echoing in any way. --- example/websocket/server/async/websocket_server_async.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/websocket/server/async/websocket_server_async.cpp b/example/websocket/server/async/websocket_server_async.cpp index 4b957086..c50ac0cb 100644 --- a/example/websocket/server/async/websocket_server_async.cpp +++ b/example/websocket/server/async/websocket_server_async.cpp @@ -126,7 +126,7 @@ public: return; if(ec) - fail(ec, "read"); + return fail(ec, "read"); // Echo the message ws_.text(ws_.got_text());