From 4d51098c86f5e99dd85eaa8c9ec5febe69795f22 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Wed, 29 Jul 2020 11:24:42 -0700 Subject: [PATCH] (websocket client) heartbeat is not sent at the requested frequency (fix #232) --- docs/CHANGELOG.md | 4 ++++ ixwebsocket/IXWebSocketTransport.cpp | 3 ++- ixwebsocket/IXWebSocketVersion.h | 2 +- ws/ws_connect.cpp | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ba18d5f0..a7153b8b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All changes to this project will be documented in this file. +## [10.1.0] - 2020-07-29 + +(websocket client) heartbeat is not sent at the requested frequency (fix #232) + ## [10.0.3] - 2020-07-28 compiler warning fixes diff --git a/ixwebsocket/IXWebSocketTransport.cpp b/ixwebsocket/IXWebSocketTransport.cpp index 8f6eb498..b7daf876 100644 --- a/ixwebsocket/IXWebSocketTransport.cpp +++ b/ixwebsocket/IXWebSocketTransport.cpp @@ -263,9 +263,10 @@ namespace ix { // compute lasting delay to wait for next ping / timeout, if at least one set auto now = std::chrono::steady_clock::now(); - lastingTimeoutDelayInMs = (int) std::chrono::duration_cast( + int timeSinceLastPingMs = (int) std::chrono::duration_cast( now - _lastSendPingTimePoint) .count(); + lastingTimeoutDelayInMs = (1000 * _pingIntervalSecs) - timeSinceLastPingMs; } #ifdef _WIN32 diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index 77b5eded..a42e7f7d 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "10.0.3" +#define IX_WEBSOCKET_VERSION "10.1.0" diff --git a/ws/ws_connect.cpp b/ws/ws_connect.cpp index 458134f3..8d177bbf 100644 --- a/ws/ws_connect.cpp +++ b/ws/ws_connect.cpp @@ -200,7 +200,7 @@ namespace ix } else if (msg->type == ix::WebSocketMessageType::Pong) { - spdlog::info("Received pong"); + spdlog::info("Received pong {}", msg->str); } else {