Description
Developing accessories for ESP8266/ESP32
I have faced a problem with DNS SD. Accessories goes offline and back online from time to time.
When this happen during the Pairing Setup - accessory become paired, and controller does not even know it, because it already closed the pairing context (due to DNS SD monitoring)
Investigating the problem I have traced all the MDNS packets and made a conclusion, the UDP packets drop cause this. Slow WiFI interfaces cant handle all the UDP milticast packets from the local network. And the bigger accessories give more UDP traffic and more drops.
This is normal to UDP - because there is no confirmation of packet receiving. And thats why DNS SD standart was designed that way, every packet has time to live (TTL) value. In our case its 120 sec for PTR record. This means, last received packet should be considered as "true" diring this TTL period. So in case an accessory (commonly low power weak device) will miss some request, it has 120 seconds to remain present.
But on practice we have other behaivour. The controller may recognize accessory goes offline even after few requests being missed. For speed LAN devices this is more or less OK situation, but not for WiFi for sure.
The only current workaround I see is to constantly keep the accessory advertising itself to fit the most of MDNS queries from controller (at least during pairing process).
But I understand this is not the way it should be done. Any sugestions welcome.
Thanks and sorry for long reading.