diff --git a/Source/MQTTnet/Client/MqttClient.cs b/Source/MQTTnet/Client/MqttClient.cs index 8556484e2..02d551f41 100644 --- a/Source/MQTTnet/Client/MqttClient.cs +++ b/Source/MQTTnet/Client/MqttClient.cs @@ -140,6 +140,7 @@ public async Task ConnectAsync(MqttClientOptions option if (connectResult.ResultCode != MqttClientConnectResultCode.Success) { _logger.Warning("Connecting failed: {0}", connectResult.ResultCode); + await DisconnectInternal(null, null, connectResult).ConfigureAwait(false); return connectResult; }