MDNS and DNS Service Discovery library


Hi all,

Just in case anyone else is watching this discussion - I think we’ve found the issue. The library is working as expected when responding to expected MDNS, service type or instance name queries, but it doesn’t support Service Type Enumeration as defined in Section 9 of the DNS-SD spec.

I’m going to raise an issue to add this to the library, but it might be a few weeks before I get around to it.





The library is now updated (v1.4.0) with support for service type enumeration and the ability to announce services on startup by passing true to mdns.begin(...).



Hi, I tried to use your mDNS library in Particle Photon. It is working well! I have a question. How can you restart or repeat advertising?

I searched new photons with a NodeJS server. If the photon is fresh restarted, then the server gets the advertisement, everything is ok. But If I start the server later then the photon, the server does not receive any message from the photon.

Can you help me?


Hi Roland,

You shouldn’t need to restart or repeat advertising. Announcing is only done on startup as per RFC 6762 section 8.3.

It sounds more likely that your queries are not being responded to. What library are you using in node.js for mdns? Have you tried installing wireshark to see the packets being sent and received by your photon and your node.js process?




I used Bonjour at nodeJS side:
Thats a good idea to check the packages with wireshark. Do the queries need some kind of respond from the NodeJS server?

I checked with wireshark the photon sends only one package, when its starts. If the NodeJs server is alive, it gets that package, else no

Thanks for your answer,



I had a quick look at the GitHub source for that library - it only appears to do passive service discovery (i.e. it will only pick up announcements as devices start up).

I only had a quick check, so might be wrong.

Ideally when you ask it to browse it should send a service enumeration query (see section 9 of RFC 6763). I suggest you try an alternative library.

What platform are you on and I can at least point you to a tool that will show your photon working (i.e. responding to service type enumeration queries).



Also, this library uses the underlying os implementation of dns service discovery (avahi daemon or Apple’s mDNSResponder) - I have tested both of these and the photon will respond to both name and service queries directly.


Yeah, mdns library works perfectly. Thanks for your answer!

Have a good day,


Hey is there a way to resolve the HOST IP if we know their broadcast name on mDNS using this library?
I couldn’t find a solution to this anywhere.


Hi @moz,

Resolve functionality isn’t currently supported (see above).




Is it possible to subscribe for services or it can still only create services? As I cannot resolve the host IP, I was planning on creating a service on my host which will transmit it’s IP address and the photon could subscribe to that service and get the host IP


Hi @moz,

Locating services (DNS-SD) uses the same resolve functionality as resolving hostnames so is not supported right now.



So that would mean there is currently no way to resolve the host IP from a particle photon using the mDNS. Is there any other way to accomplish something similar in a dynamic network system? The ultimate purpose of introducing the mDNS was to solve this issue but it is sad to see it is not available on the particle yet.


Can you point me to exactly what all will be needed to add this functionality as I want to do it. As far as I understand, it would require to form a QTYPE A packet and transmit it on the group. After which it waits for a response. It takes in the response, parse them and take out the IP address of the sender/host.
Is there any hints or tips you would want to give? What are the specific functions in your library that will help me in this?


Hi @moz,

Correct, you can re-use some of the existing classes to build a query packet, send it out over UDP and then wait for responses. You’d need to consider how long you want to block waiting for responses or whether you can successfully poll for a response every so often.



Hey. I was testing your example function and after some time the core-1.local/ seems to stop working. I am guessing it is disconnecting from the mDNS group. Any ideas on why this is happening?


Hi @moz,

I’ve seen issues with this in the past, but not for a while. What hardware are you using and which version of firmware? Have you modified the sample code at all?

I’ll try to replicate if you can give me the above details.




I was using a particle photon with base OS as 1.2.0 and the code was target at 1.1.0-rc.2
I was using your base code without any modifications


Hi @moz,

I’ve just tried to replicate your issue and I’m not having any luck. I’m using the web ide so could only target 1.2.1, but my Photon has been up and responding to continual connections to it’s http service for over 40 minutes. I’ve seen one or two closed connections and a pause of a few seconds here and there, but it always continues shortly afterwards.

When you say it stops working what exactly is happening? Is it failing to respond to MDNS requests or failing to respond to HTTP (on port 80 or 8080?)



So what was happening was I was not ale to access the core-1.local/ from my browser after some time.