fix(signalk): add mDNS settle delay and backoff to fix Ethernet race#851
fix(signalk): add mDNS settle delay and backoff to fix Ethernet race#851dirkwa wants to merge 1 commit intoSignalK:mainfrom
Conversation
On Ethernet, DHCP completes faster than on WiFi, which means the first MDNS.queryService() call fires before the mDNS stack has joined its multicast groups on the new interface. This causes the server discovery to silently return 0 results even when the Signal K server is present, and the 2-second flat retry loop spins indefinitely without connecting. Two-part fix: 1. Settle delay: subscribe to ARDUINO_EVENT_ETH_GOT_IP and ARDUINO_EVENT_WIFI_STA_GOT_IP. On each event, reset mdns_ready_ and arm a 4-second one-shot timer via event_loop()->onDelay(). mDNS queries are blocked until the timer fires. 2. Exponential backoff: after a failed mDNS query, double the retry interval (starting at 5s, capped at 60s) instead of hammering queryService() every 2 seconds. Both the settle timer and the backoff counter are reset when the network gets a new IP (e.g. after a cable reconnect), so recovery is still fast.
99ff1d0 to
bf92d1c
Compare
|
Claude-generated review, curated: Review SummaryThe core finding: the 4-second hard-coded settle delay is both unnecessary and harmful. The key argument against
|
On Ethernet, DHCP completes faster than on WiFi, which means the first MDNS.queryService() call fires before the mDNS stack has joined its multicast groups on the new interface. This causes the server discovery to silently return 0 results even when the Signal K server is present, and the 2-second flat retry loop spins indefinitely without connecting.
Two-part fix:
Settle delay: subscribe to ARDUINO_EVENT_ETH_GOT_IP and ARDUINO_EVENT_WIFI_STA_GOT_IP. On each event, reset mdns_ready_ and arm a 4-second one-shot timer via event_loop()->onDelay(). mDNS queries are blocked until the timer fires.
Exponential backoff: after a failed mDNS query, double the retry interval (starting at 5s, capped at 60s) instead of hammering queryService() every 2 seconds.
Both the settle timer and the backoff counter are reset when the network gets a new IP (e.g. after a cable reconnect), so recovery is still fast.