0 Replies Latest reply on Feb 14, 2015 11:26 AM by Jon Tara

    mDNS Service Discovery (Bonjour)

    Jon Tara

      It doesn't seem Rhodes has any built-in support for mDNS Service Discovery (Bonjour). Is that right?


      Has anyone implemented it, and willing to share, or know of an open-source project with a Rhodes extension for this?


      I note that Ruby 2.1 standard library has Resolv:MDNS built-in, and this would be sufficient for my needs, but Rhodes (in app) uses old Ruby 1.9.2-p290 so that doesn't help.


      As well, Ruby 2.x has Net::DNS::MDNS (more fully fleshed-out, but I don't need the fancy stuff) again built in to the standard library. But again Ruby 2.x.


      And, anyway, Rhodes doesn't implement everything in the standard library anyway, so not waiting for this.


      So, this:

         tenderlove/dnssd · GitHub


      is a popular Ruby interface for Ruby < 2.x


      But eek it uses Ruby threads, which work great in Rhodes on iOS (I used them in watusi-rhodes-xmpp) but not at all on Android (progress report? Will Ruby threads ever happen on Android?)


      It uses native dns-sd library on OS X, and includes a C dns-sd for Windows.


      Fortunately, dns-sd is exposed in iOS, though Apple would rather you use a higher-level framework:


          Introduction to DNS Service Discovery


      So it looks like I can easily make this into a Rhodes extension that will work on iOS. If I do, I'll share it.


      There is a synchronous method for resolution (resolution is all I need)  - so in that case no Ruby thread - and so that provides a (less than ideal) solution for Android. (It will block during resolution). IF Android has a dns-sd library exposed (I realize it has a Java interface in the API, I'd rather no have to write the connector code...) and IF (either of those) that actually works (anecdotal evidence is that it is flakey, but I hope better on more recent API versions?) Otherwise, there is this:


          waiter - A simple, well coded DNS-SD and MulticastDNS library for Java using a clean, modern DNS library - Google Proj…


      But I think that is going down a rabbit hole.


      Can't image there isn't anyone here who has needed DNS service discovery. Ideas? If you have implemented it, how did you solve it?