From e0660ba8871e248efbbd1a7078bf7296caeca568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Jecha?= Date: Fri, 1 Sep 2023 18:58:36 +0200 Subject: [PATCH] #1810 Close connection after failed connect. (#1811) --- Source/MQTTnet/Client/MqttClient.cs | 1 + 1 file changed, 1 insertion(+) 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; }