Skip to content

Commit

Permalink
Fix possible MQTT disconnect exception
Browse files Browse the repository at this point in the history
  • Loading branch information
arendst committed Sep 9, 2023
1 parent f9fd813 commit 0e6a012
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ bool MqttIsConnected(void) {
}

void MqttDisconnect(void) {
MqttClient.disconnect();
if (MqttClient.connected()) {
MqttClient.disconnect();
}
}

void MqttSubscribeLib(const char *topic) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0e6a012

Please # to comment.