Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of: 2129 cancellation token backport #2144

Merged
merged 4 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
* Core: Fixed issue when parsing AUTH packet with 0 length body (#2039).
* nuget: Changed code signing and nuget certificate (**BREAKING CHANGE**).
* TopicTemplates: Updated samples, parameter validation (#2022).
* ManagedClient: Switch SubscribeAsync/UnsubscribeAsync to IEnumerable<string> (#2026).
* Server: Fix _LoadingRetainedMessageAsync_ not executed (#2025).
* Client: Fixed wrong timeout for keep alive check (thanks to @Erw1nT, #2129)
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on: [push, pull_request]

env:
VERSION: "4.3.7.${{github.run_number}}"
VERSION: "4.3.8.${{github.run_number}}"

jobs:
build:
Expand All @@ -12,7 +12,7 @@ jobs:

steps:
- name: Setup Windows SDK
uses: GuillaumeFalourd/setup-windows10-sdk-action@v1
uses: GuillaumeFalourd/setup-windows10-sdk-action@v2.4
with:
sdk-version: 18362

Expand Down
9 changes: 6 additions & 3 deletions Source/MQTTnet/Client/MqttClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,10 +1051,13 @@ async Task TrySendKeepAliveMessages(CancellationToken cancellationToken)

if (timeWithoutPacketSent > keepAlivePeriod)
{
using (var timeoutCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken))
using (var pingTimeout = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken))
{
timeoutCancellationTokenSource.CancelAfter(Options.Timeout);
await PingAsync(timeoutCancellationTokenSource.Token).ConfigureAwait(false);
// We already reached the keep alive timeout. Due to the RFC part [MQTT-3.1.2-24] the server will wait another
// 1/2 of the keep alive time. So we can also use this value as the timeout.
pingTimeout.CancelAfter((int)(keepAlivePeriod.TotalMilliseconds / 2));

await PingAsync(pingTimeout.Token).ConfigureAwait(false);
}
}

Expand Down
Loading