fix(mqtt): count failed starts and ignore bounced sessions in cf

connect()/reconnect() returning an error started no attempt, so no event
arrived and the failure went uncounted -- the low-heap case the counter exists
for. Counted now in a bridge-task-only start_failures, summed into cf: and
mqtt_connect_failures.

A renewal or corrected-clock bounce whose softDisconnect() times out gets its
old session's DISCONNECTED after the new attempt raised the flag. That session
is still marked connected until the handler runs, so the gate now also
requires !connected. An ignored late CONNECTED clears the flag too.

cf: no longer depends on dc being non-zero. Comments corrected for the
PSRAM-fallback stack cost and heap_largest's sampling point; the worst-case
test now models 6 slots.
This commit is contained in:
agessaman committed 2026-09-26 12:25:53 -07:00
1 parent 2f6d139729
commit 99a4b6fad0
4 files changed
+25 -14

No files matched your search

@@ -222,11 +222,11 @@ TEST(MQTTPayloadBuilder, WorstCaseStatusWithConnectionHealthFitsProductionBuffer
char buffer[kStatusJsonBufferSize];
MQTTConnHealth health;
health.slots_up = 0;
health.slots_total = 5; // PSRAM slot cap, the widest configuration
health.slots_total = 6; // RUNTIME_MQTT_SLOTS on PSRAM, the widest
health.worst_outage_secs = 4294967; // millis() rollover / 1000, the widest value
health.heap_largest = 8388608;
health.connect_failures = 2147483647;
health.slots_breaker = 5;
health.slots_breaker = 6;
int len = MQTTPayloadBuilder::buildStatusMessage(
scratch, origin.c_str(), origin_id.c_str(), model.c_str(), firmware.c_str(),