Repository navigation
fix: increase WiFi shutdown delay before restart to fix MQTT reconnect after OTA - #55
netscout2001 wants to merge 1 commit into
Conversation
|
Please retest the latest beta firmware that includes the network/web runtime refactor originally introduced in commit 5f4e9d8 (Refactor network and web runtime architecture). Recommended test build: This refactor changed the internal architecture of networking, MQTT, web runtime handling, OTA flow, and cross-thread interaction between the web layer, UI layer, and network task. |
|
Hi @netscout2001, Thank you again for investigating the MQTT reconnect problem after OTA! Your finding that Wi-Fi and TCP needed more time to shut down before restart was incorporated into the final implementation. I used an explicit Wi-Fi disconnect followed by a 250 ms shutdown window, together with the broader restart cleanup, in 507abec. I’m now improving how Project Aura records community contributions. The project has an Individual Contributor License Agreement, and I’d appreciate it if you could read the current CLA. If you’re happy with it, please post the following exact text as a separate comment containing only this sentence:
Separately from the CLA, I’d like to record this PR properly and credit you for the shutdown-timing finding. If you would like commit-level co-author attribution where appropriate, one reply with your preferred name and GitHub-associated email (a GitHub Thanks again for helping make OTA restarts more reliable! |
Problem
After any software-triggered restart (OTA update, web dashboard restart button,
MQTT restart command) the device fails to reconnect to the MQTT broker and
requires a full power cycle to restore the connection.
Root cause
All three restart paths call
esp_wifi_stop()followed by a shortdelay()before
safe_restart_via_core0(). The delay is too short for the WiFi and TCPstacks to complete their shutdown sequences. As a result the MQTT broker still
considers the previous TCP session active when the device comes back up, causing
the reconnect to fail.
Fix
Increased the delay from its current value to 250 ms in all three restart paths.
250 ms is sufficient for WiFi to send the Disassociation frame and for the TCP
stack to send RST on all open sockets including the MQTT connection.
src/main.cpp— OTA reboot pathThe additional delay is imperceptible during a reboot sequence that already
takes several seconds.
Checklist