浏览代码

Respect keep alive interval after sending

release/3.x.x
Christoph Stichlberger 6 年前
父节点
当前提交
b38df9eecd
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. +4
    -2
      Frameworks/MQTTnet.NetStandard/Client/MqttClient.cs

+ 4
- 2
Frameworks/MQTTnet.NetStandard/Client/MqttClient.cs 查看文件

@@ -419,12 +419,14 @@ namespace MQTTnet.Client
keepAliveSendInterval = _options.KeepAliveSendInterval.Value;
}

if (_sendTracker.Elapsed > keepAliveSendInterval)
var waitTime = keepAliveSendInterval - _sendTracker.Elapsed;
if (waitTime <= TimeSpan.Zero)
{
await SendAndReceiveAsync<MqttPingRespPacket>(new MqttPingReqPacket()).ConfigureAwait(false);
waitTime = keepAliveSendInterval;
}

await Task.Delay(keepAliveSendInterval, _cancellationTokenSource.Token).ConfigureAwait(false);
await Task.Delay(waitTime, _cancellationTokenSource.Token).ConfigureAwait(false);
}
}
catch (Exception exception)


正在加载...
取消
保存