mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-28 17:22:37 +08:00
Apply timeout to automatic ping. (#1495)
Co-authored-by: Stan Wijckmans <stanw@aviobook.aero>
This commit is contained in:
co-authored by
Stan Wijckmans
parent
12dd815421
commit
c5cec60809
@@ -523,7 +523,11 @@ namespace MQTTnet.Client
|
|||||||
|
|
||||||
if (timeWithoutPacketSent > keepAlivePeriod)
|
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
|
// Wait a fixed time in all cases. Calculation of the remaining time is complicated
|
||||||
|
|||||||
Reference in New Issue
Block a user