-
-
Notifications
You must be signed in to change notification settings - Fork 6
Refactors mdns-discovery to better handle add and remove events
#14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6892ce3 to
29ef714
Compare
|
When touching this library, make sure not to reintroduce some bugs long fixed in the java IDE (like to ones linked here arduino/Arduino#5879 ).
|
ubidefeo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on Mac OS (on which it was problematic) and it works.
Even sees other devices on my network, which is a welcome change ✌🏼
|
@facchinm no worries, the CPU usage is minimal, it never went more than 0.8% for me on Linux. |
|
I'd suggest to test on a Windows pc with 5 network interfaces but it's not so easy to find 😅 |
Right now
mdns-discoveryhas some issues caused by the mDNS library in use and by technical limitations of the mDNS protocol.Because of the way the mDNS protocol works we have no way of knowing if a device has been disconnected from the network, only when it's connected/discovered.
The best way to handle this is to use TTLs and send a
removeevent when the TTL is reached. But the library we're usinggithub.com/brutella/dnssddoesn't handle TTLs correctly so we never receives disconnections events from it. Also we don't have much granular control of the discovery process with this library.I changed the library used to
github.com/hashicorp/mdnsand the internal behaviour of the discovery process.Every 15 seconds we query the network to know if there are boards connected, each discovered port is cached with a TTL of 60 seconds and an
addevent is sent to consumers.Each time we find a board we first check if it's cached, if it is we renew the TTL to 60 seconds. No
addevent is sent in this case.When the TTL ends the board is removed from cache and a
removeevent is sent to consumers.