From 6bc96ca0b361f143504cfc2fdc04f724301cbb9b Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Filho Date: Tue, 9 Sep 2025 16:19:41 +0200 Subject: [PATCH] fix: Allow mqtt client to gracefully disconnect when stop Previously the failure to create a disconnect message would lead the client to an incorrect state if called in the process of destroy. --- mqtt_client.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mqtt_client.c b/mqtt_client.c index 6f0158f..dd0ca7f 100644 --- a/mqtt_client.c +++ b/mqtt_client.c @@ -1942,10 +1942,7 @@ esp_err_t esp_mqtt_client_stop(esp_mqtt_client_handle_t client) // Only send the disconnect message if the client is connected if (client->state == MQTT_STATE_CONNECTED) { - if (send_disconnect_msg(client) != ESP_OK) { - MQTT_API_UNLOCK(client); - return ESP_FAIL; - } + send_disconnect_msg(client); } client->run = false;