未验证 提交 c5cec608 编写于 作者: S Stan Wijckmans 提交者: GitHub

Apply timeout to automatic ping. (#1495)

Co-authored-by: NStan Wijckmans <stanw@aviobook.aero>
上级 12dd8154
......@@ -523,7 +523,11 @@ namespace MQTTnet.Client
if (timeWithoutPacketSent > keepAlivePeriod)
{
await PingAsync(cancellationToken).ConfigureAwait(false);
using (var timeoutCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken))
{
timeoutCancellationTokenSource.CancelAfter(Options.Timeout);
await PingAsync(timeoutCancellationTokenSource.Token).ConfigureAwait(false);
}
}
// Wait a fixed time in all cases. Calculation of the remaining time is complicated
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册