From f9fd813842e543eb371e18c1b8b37dc25f91ed0b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 9 Sep 2023 23:04:08 +0200 Subject: [PATCH] Fix core 2.0.12 exception --- tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino b/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino index 849220e0f..2b1f646de 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino @@ -911,9 +911,11 @@ void MqttDisconnected(int state) { Mqtt.retry_counter_delay++; } - MqttClient.disconnect(); - // Check if this solves intermittent MQTT re-connection failures when broker is restarted - EspClient.stop(); + if (MqttClient.connected()) { + MqttClient.disconnect(); + // Check if this solves intermittent MQTT re-connection failures when broker is restarted + EspClient.stop(); + } AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECT_FAILED_TO " %s:%d, rc %d. " D_RETRY_IN " %d " D_UNIT_SECOND), SettingsText(SET_MQTT_HOST), Settings->mqtt_port, state, Mqtt.retry_counter);