fix: increase check time and add random wait to avoid service collisions #1611
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.
Problem
Service registration conflicts were occurring frequently on WiFi networks and with slow IoT devices. The probe responses from existing services weren't arriving within the default 175ms check window, causing false positives for available names and subsequent conflicts.
Solution
This PR improves mDNS service registration reliability by implementing two RFC 6762 recommended timing adjustments:
Random startup delay (RFC 6762, Section 8.1): Added a random 150-250ms delay before sending the first probe query to avoid the "thundering herd" problem when multiple services start simultaneously
Increased check interval: Extended
_CHECK_TIMEfrom 175ms to 500ms to accommodate slower WiFi and IoT devices while remaining RFC-compliant (the RFC specifies "should" for 250ms intervals, allowing flexibility for network conditions)Changes
src/zeroconf/const.py: Increased_CHECK_TIMEfrom 175ms to 500mssrc/zeroconf/_core.py: Added random 150-250ms initial delay before first probe (line 551)Impact
Testing
Verified with:
dns-sdagainst Linuxavahi-daemonFixes service registration reliability issues reported when running development instances over WiFi.