Skip to content

Commit

Permalink
Fix issues with exception handling after disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
chkr1011 committed Sep 20, 2017
1 parent dcf6f94 commit 50800b1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions MQTTnet.Core/Client/MqttClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ private async Task SendKeepAliveMessagesAsync(CancellationToken cancellationToke
}
catch (MqttCommunicationException exception)
{
if (cancellationToken.IsCancellationRequested)
{
return;
}

MqttTrace.Warning(nameof(MqttClient), exception, "MQTT communication exception while sending/receiving keep alive packets.");
await DisconnectInternalAsync().ConfigureAwait(false);
}
Expand Down Expand Up @@ -388,6 +393,11 @@ private async Task ReceivePackets(CancellationToken cancellationToken)
}
catch (MqttCommunicationException exception)
{
if (cancellationToken.IsCancellationRequested)
{
return;
}

MqttTrace.Warning(nameof(MqttClient), exception, "MQTT communication exception while receiving packets.");
await DisconnectInternalAsync().ConfigureAwait(false);
}
Expand Down

0 comments on commit 50800b1

Please sign in to comment.