From c6f4b594382f33089946f6169921cb651a42bfda Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 8 Jan 2022 15:35:47 +0100 Subject: [PATCH] Increase delay for Keep Alive checks to decrease CPU load. --- Source/MQTTnet/Client/MqttClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/MQTTnet/Client/MqttClient.cs b/Source/MQTTnet/Client/MqttClient.cs index 781ddd0..9c091ca 100644 --- a/Source/MQTTnet/Client/MqttClient.cs +++ b/Source/MQTTnet/Client/MqttClient.cs @@ -455,7 +455,7 @@ namespace MQTTnet.Client _logger.Verbose("Start sending keep alive packets."); var keepAlivePeriod = Options.KeepAlivePeriod; - + while (!cancellationToken.IsCancellationRequested) { // Values described here: [MQTT-3.1.2-24]. @@ -470,7 +470,7 @@ namespace MQTTnet.Client // due to some edge cases and was buggy in the past. Now we wait several ms because the // min keep alive value is one second so that the server will wait 1.5 seconds for a PING // packet. - await Task.Delay(TimeSpan.FromMilliseconds(100), cancellationToken).ConfigureAwait(false); + await Task.Delay(250, cancellationToken).ConfigureAwait(false); } } catch (Exception exception)