Fixes #1276 timestamp check in server keep-alive monitor (#1277)

* Fix timestamp check in server keep-alive monitor

* Retain the original client statistics property name
- add comments to clarify meaning
- add separate public "received" timestamp property

* fix comment
This commit is contained in:
logicaloud
2021-10-30 10:12:57 +02:00
committed by GitHub
parent d7e1c89d62
commit 1e68c2e815
3 changed files with 45 additions and 3 deletions
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading;
using System.Threading.Tasks;
using MQTTnet.Client.Disconnecting;
@@ -95,7 +95,7 @@ namespace MQTTnet.Server.Internal
// If the client sends 1 sec. the server will allow up to 1.5 seconds.
var maxDurationWithoutPacket = connection.KeepAlivePeriod * 1.5D;
var secondsWithoutPackage = (now - connection.Statistics.LastPacketReceivedTimestamp).TotalSeconds;
var secondsWithoutPackage = (now - connection.Statistics.LastPacketSentTimestamp).TotalSeconds;
if (secondsWithoutPackage < maxDurationWithoutPacket)
{
// A packet was received before the timeout is affected.