diff --git a/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino b/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino index 2b1f646de..91eb1ef6d 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino @@ -465,7 +465,9 @@ bool MqttIsConnected(void) { } void MqttDisconnect(void) { - MqttClient.disconnect(); + if (MqttClient.connected()) { + MqttClient.disconnect(); + } } void MqttSubscribeLib(const char *topic) { @@ -1060,8 +1062,7 @@ void MqttReconnect(void) { AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_ATTEMPTING_CONNECTION)); - if (MqttClient.connected()) { MqttClient.disconnect(); } - + MqttDisconnect(); MqttSetClientTimeout(); MqttClient.setCallback(MqttDataHandler);