Fix issues with exception handling after disconnect

This commit is contained in:
Christian Kratky
2017-09-20 21:36:32 +02:00
parent dcf6f94d77
commit 50800b1d44
+10
View File
@@ -352,6 +352,11 @@ namespace MQTTnet.Core.Client
}
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);
}
@@ -388,6 +393,11 @@ namespace MQTTnet.Core.Client
}
catch (MqttCommunicationException exception)
{
if (cancellationToken.IsCancellationRequested)
{
return;
}
MqttTrace.Warning(nameof(MqttClient), exception, "MQTT communication exception while receiving packets.");
await DisconnectInternalAsync().ConfigureAwait(false);
}