From fcb92f862dcd85240c2c36dba348f7ec90672300 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Tue, 18 Aug 2020 14:09:27 -0700 Subject: [PATCH] (ws push_server) on the server side, stop sending and close the connection when the remote end has disconnected --- docs/CHANGELOG.md | 4 ++++ ixwebsocket/IXWebSocketVersion.h | 2 +- ws/ws.cpp | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c76f9894..1e8f1279 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,10 @@ All changes to this project will be documented in this file. +## [10.2.7] - 2020-08-18 + +(ws push_server) on the server side, stop sending and close the connection when the remote end has disconnected + ## [10.2.6] - 2020-08-17 (ixwebsocket) replace std::unique_ptr with std::array for some fixed arrays (which are in C++11) diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index 7ee42087..5217d786 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "10.2.6" +#define IX_WEBSOCKET_VERSION "10.2.7" diff --git a/ws/ws.cpp b/ws/ws.cpp index 66829a1d..7daf3b56 100644 --- a/ws/ws.cpp +++ b/ws/ws.cpp @@ -1692,7 +1692,13 @@ namespace ix bool binary = false; while (true) { - webSocket.send(sendMsg, binary); + auto sendInfo = webSocket.send(sendMsg, binary); + if (!sendInfo.success) + { + spdlog::info("Error sending message, closing connection"); + webSocket.close(); + break; + } } } else if (msg->type == ix::WebSocketMessageType::Close)