mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
force mqtt disconnect on wifi disconnect
This commit is contained in:
@@ -118,7 +118,7 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
||||
if (_state.enabled) {
|
||||
// emsesp::EMSESP::logger().info("Network connection dropped, stopping MQTT client");
|
||||
_mqttClient.disconnect();
|
||||
_mqttClient.disconnect(true);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -129,7 +129,7 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
|
||||
bool MqttSettingsService::configureMqtt() {
|
||||
// disconnect if connected
|
||||
_mqttClient.disconnect();
|
||||
_mqttClient.disconnect(true);
|
||||
// only connect if WiFi is connected and MQTT is enabled
|
||||
if (_state.enabled && emsesp::EMSESP::system_.network_connected() && !_state.host.isEmpty()) {
|
||||
// emsesp::EMSESP::logger().info("Configuring MQTT client");
|
||||
|
||||
Reference in New Issue
Block a user