From f64852e223296b36cb75c825af6d1aecdc1636e2 Mon Sep 17 00:00:00 2001 From: agessaman Date: Fri, 14 Aug 2026 09:53:38 -0700 Subject: [PATCH] fix(mqtt): log a failed client start instead of reporting success connect() logged "MQTT client started." unconditionally, so a failing esp_mqtt_client_start() looked identical to a successful one. That is the one state a later reconnect() cannot recover from, which made it the worst possible line to be wrong. --- lib/PsychicMqttClient/src/PsychicMqttClient.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/PsychicMqttClient/src/PsychicMqttClient.cpp b/lib/PsychicMqttClient/src/PsychicMqttClient.cpp index 5d037b7e3..ba1dc5f19 100644 --- a/lib/PsychicMqttClient/src/PsychicMqttClient.cpp +++ b/lib/PsychicMqttClient/src/PsychicMqttClient.cpp @@ -438,8 +438,13 @@ void PsychicMqttClient::connect() if (start_result == ESP_OK) { _started = true; + ESP_LOGI(TAG, "MQTT client started."); + } + else + { + // Reporting success here hides the one state reconnect() cannot recover from. + ESP_LOGE(TAG, "MQTT client failed to start: %s", esp_err_to_name(start_result)); } - ESP_LOGI(TAG, "MQTT client started."); } void PsychicMqttClient::reconnect()