mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-09-13 13:44:10 +00:00
prevent unsuccessful mqtt connections, dev7
This commit is contained in:
+3
-4
@@ -351,6 +351,7 @@ void Mqtt::reset_mqtt() {
|
|||||||
if (mqttClient_->connected()) {
|
if (mqttClient_->connected()) {
|
||||||
mqttClient_->disconnect(true); // force a disconnect
|
mqttClient_->disconnect(true); // force a disconnect
|
||||||
}
|
}
|
||||||
|
load_settings(); // reload MQTT settings
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the settings from service
|
// load the settings from service
|
||||||
@@ -502,8 +503,8 @@ void Mqtt::on_disconnect(espMqttClientTypes::DisconnectReason reason) {
|
|||||||
|
|
||||||
// MQTT on_connect - when an MQTT connect is established
|
// MQTT on_connect - when an MQTT connect is established
|
||||||
void Mqtt::on_connect() {
|
void Mqtt::on_connect() {
|
||||||
if (connecting_) {
|
if (connecting_ || !connected()) {
|
||||||
return; // prevent duplicated connections
|
return; // prevent duplicated connections and unsuccessful tries
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("MQTT connected");
|
LOG_INFO("MQTT connected");
|
||||||
@@ -511,8 +512,6 @@ void Mqtt::on_connect() {
|
|||||||
connecting_ = true;
|
connecting_ = true;
|
||||||
queuecount_ = mqttClient_->queueSize();
|
queuecount_ = mqttClient_->queueSize();
|
||||||
|
|
||||||
load_settings(); // reload MQTT settings - in case they have changes
|
|
||||||
|
|
||||||
if (ha_enabled_) {
|
if (ha_enabled_) {
|
||||||
queue_unsubscribe_message(discovery_prefix_ + "/+/" + Mqtt::basename() + "/#");
|
queue_unsubscribe_message(discovery_prefix_ + "/+/" + Mqtt::basename() + "/#");
|
||||||
EMSESP::reset_mqtt_ha(); // re-create all HA devices if there are any
|
EMSESP::reset_mqtt_ha(); // re-create all HA devices if there are any
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.9.0-dev.6"
|
#define EMSESP_APP_VERSION "3.9.0-dev.7"
|
||||||
|
|||||||
Reference in New Issue
Block a user