Fix possible MQTT disconnect exception

This commit is contained in:
Theo Arends 2023-09-09 23:30:55 +02:00
parent f9fd813842
commit 0e6a012499
1 changed files with 4 additions and 3 deletions

View File

@ -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);