Repository navigation
Bound the TCP connect to a printer that does not answer - #30
Open
Ptitlouis6012 wants to merge 1 commit into
Open
Ptitlouis6012 wants to merge 1 commit into
Ptitlouis6012 wants to merge 1 commit into
Conversation
WiFiClientSecure waits thirty seconds for a host that does not answer, and the loop watchdog is thirty seconds. The MQTT socket timeout and the TLS handshake timeout set beside it bound neither: the connect has its own. So a LAN Bambu or Anycubic that was switched off froze the panel for the whole wait and then the watchdog restarted the box, which tried the same printer again - a restart every fifty seconds until the printer was turned on, with the touch dead and the account stuck orange because its exchange could never finish. net_.setTimeout() bounds the connect: four seconds for a printer on the LAN, eight for the Bambu cloud broker, which is across the internet. A printer that is off now fails in four seconds and the link logic retries as it always did.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
A LAN Bambu (or Anycubic) that is switched off restarted the box in a loop.
WiFiClientSecurewaits thirty seconds for a host that does not answer (_timeout = 30000, then aselecton the TCP connect inssl_client.cpp), and the loop watchdog isLOOP_WDT_S = 30. ThesetSocketTimeout(4)andsetHandshakeTimeout(5)set beside it bound neither: the connect has its own limit. So a printer that was off froze the loop for the whole wait, the watchdog fired, the box restarted and tried the same printer again — a restart every ~50 s until the printer was turned on. In between the touch was dead, and the account icon stayed orange because its exchange could never finish.The fix is one call where each client is set up:
backend_bambu.cpp:net_.setTimeout(4), a printer on the LAN answers in milliseconds.backend_anycubic.cpp: the same, for a LAN Anycubic.bambu_cloud.cpp:setTimeout(8), the broker is across the internet.The Anycubic cloud session (
LegacyTlsClient) already bounds its connect to 5 s, and the Elegoo, FlashForge, Creality and Snapmaker paths do not useWiFiClientSecure.What you tested it on
A TigerSpool (ESP32-S3-Touch-LCD-2) on firmware 1.72.0 with a K2 and a P2S (LAN mode) in the account.
[link] attempt 1/5 to P2S,[bambu] connecting to 192.168.1.4:8883..., thentask_wdt: loopTaskand a reboot, every ~50 s, over 80 s of serial log (4 reboots).Bambu: MQTT rc=-2), the link gives up after five tries and retries as it always did, 0 watchdog resets. The touch works and the account icon is green. With the printers on it starts as before (2 link(s) up).What is not fixed: while a printer stays unreachable each attempt still blocks the loop for up to four seconds, so the screen answers within about four to six seconds rather than instantly (a request took 5.7 s, a tap 4.4 s). That is far better than a freeze and a restart, but a probe that does not block the loop would be the real answer; I kept this change to the one line that stops the restarts.
Not tested: a K2 off on its own, and the Creality and Snapmaker paths.
bash scripts/verify.sh --quickpasses except "generated files match their generator", which also fails on a cleanmainon the machine used.Checklist
CHANGELOG.mdupdated for anything user-visible. (left to the release ritual)