Skip to content

Commit

Permalink
Cancel send operations at diconnection to avoid endless blocking (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasSeidenbecher authored Sep 21, 2022
1 parent 10a7d06 commit 6850bbd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Client/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async Task TrySendKeepAliveMessagesAsync( CancellationToken cancellationToken )
Logger.Error( "Error exception while sending/receiving keep alive packets. " + exception );
}

await m_MqttClient?.DisconnectAsync();
await m_MqttClient?.DisconnectAsync(MqttClientDisconnectReason.KeepAliveTimeout);
}
finally
{
Expand Down Expand Up @@ -892,7 +892,7 @@ private void Publish( byte[] payload, string topicPrefix, ushort dataSetWriterId
{
try
{
m_MqttClient.PublishAsync(messageBuilder.Build())
m_MqttClient.PublishAsync(messageBuilder.Build(), m_BackgroundCancellationToken.Token)
.Wait();

m_LastPacketSentTimestamp = DateTime.UtcNow;
Expand Down

0 comments on commit 6850bbd

Please sign in to comment.