mirror of
https://github.com/mikecarper/MeshCore.git
synced 2026-10-23 08:43:48 +00:00
fix(mqtt): count only failed starts, not rejected reconnects, in cf
reconnect() on a started client returns ESP_FAIL while an attempt is already in progress. On a Heltec V3, a live reconfigure hit exactly that and the attempt then connected, yet cf read 1. Count start_failures only when connect() on a stopped client fails, and restore the attempt flag to its prior value on any failed call so the in-progress attempt is still judged by its own outcome.
This commit is contained in:
1 parent
6390763c71
commit
f37445f8a7
2 files changed
+11
-6
No files matched your search
@@ -2512,8 +2512,10 @@ esp_err_t MQTTBridge::reconnectSlotClient(int index) {
|
||||
}
|
||||
|
||||
esp_err_t r;
|
||||
const bool was_pending = _slot_attempt_pending[index];
|
||||
const bool starting = !slot.client->isStarted();
|
||||
_slot_attempt_pending[index] = true;
|
||||
if (!slot.client->isStarted()) {
|
||||
if (starting) {
|
||||
MQTT_DEBUG_PRINTLN("MQTT%d start (client was stopped)", index + 1);
|
||||
r = slot.client->connect();
|
||||
} else {
|
||||
@@ -2526,8 +2528,11 @@ esp_err_t MQTTBridge::reconnectSlotClient(int index) {
|
||||
// is the point at which a freshly minted token becomes the one in use.
|
||||
slot.applied_token_expires_at = slot.token_expires_at;
|
||||
} else {
|
||||
_slot_attempt_pending[index] = false;
|
||||
slot.start_failures++;
|
||||
_slot_attempt_pending[index] = was_pending;
|
||||
// A failed start (buffer/task allocation, config) means no attempt could begin.
|
||||
// reconnect() on a started client returns ESP_FAIL while one is already in
|
||||
// progress, which is not a failure (seen on hardware after a reconfigure).
|
||||
if (starting) slot.start_failures++;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -187,9 +187,9 @@ private:
|
||||
// disconnect_count (which also counts dropped live sessions) and from the
|
||||
// publish error counter, which cannot move at all while a slot is down.
|
||||
uint32_t connect_failures;
|
||||
// connect()/reconnect() calls that returned an error, so no attempt started and
|
||||
// no event will arrive. Written only by the bridge task; reported summed with
|
||||
// connect_failures.
|
||||
// connect() calls on a stopped client that returned an error, so no attempt
|
||||
// started and no event will arrive. Written only by the bridge task; reported
|
||||
// summed with connect_failures.
|
||||
uint32_t start_failures;
|
||||
unsigned long first_disconnect_time; // millis() of first disconnect after boot
|
||||
|
||||
|
||||
Reference in new issue
Block a user