From f51e332148bcc99a5af0b4061cd300bde6b9809c Mon Sep 17 00:00:00 2001 From: Peter Giacomo Lombardo Date: Tue, 2 Jul 2024 12:12:35 +0200 Subject: [PATCH] Fix: Timer reset only on egress (#183) --- Source/HiveMQtt/Client/HiveMQClientTrafficProcessor.cs | 3 +-- Source/HiveMQtt/Client/Options/HiveMQClientOptions.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/HiveMQtt/Client/HiveMQClientTrafficProcessor.cs b/Source/HiveMQtt/Client/HiveMQClientTrafficProcessor.cs index ed76aa66..c9109bdd 100644 --- a/Source/HiveMQtt/Client/HiveMQClientTrafficProcessor.cs +++ b/Source/HiveMQtt/Client/HiveMQClientTrafficProcessor.cs @@ -84,7 +84,7 @@ private Task ConnectionMonitorAsync(CancellationToken cancellationToken) => Task { try { - // If connected and no recent traffic, send a ping + // If connected and no recent packets have been sent, send a ping if (this.ConnectState == ConnectState.Connected) { if (this.lastCommunicationTimer.Elapsed > TimeSpan.FromSeconds(keepAlivePeriod)) @@ -949,7 +949,6 @@ internal async ValueTask ReadAsync(CancellationToken cancellationTok } var readResult = await this.Reader.ReadAsync(cancellationToken).ConfigureAwait(false); - this.lastCommunicationTimer.Restart(); return readResult; } } diff --git a/Source/HiveMQtt/Client/Options/HiveMQClientOptions.cs b/Source/HiveMQtt/Client/Options/HiveMQClientOptions.cs index 2c32722d..e1717bf4 100644 --- a/Source/HiveMQtt/Client/Options/HiveMQClientOptions.cs +++ b/Source/HiveMQtt/Client/Options/HiveMQClientOptions.cs @@ -61,7 +61,7 @@ public HiveMQClientOptions() // When resolving a DNS hostname in the Host property, prefer IPv6 addresses over IPv4 addresses. public bool PreferIPv6 { get; set; } - // The the maximum time interval that is permitted to elapse between the point at which the Client + // The the maximum time interval in seconds that is permitted to elapse between the point at which the Client // finishes transmitting one MQTT Control Packet and the point it starts sending the next. // Valid values: 0..65535 public int KeepAlive { get; set; }