Querying DNS SRV for broker address

1,281 views
Skip to first unread message

Roger Light

unread,
Nov 12, 2013, 12:14:57 PM11/12/13
to mq...@googlegroups.com
Hi all,

I've been playing a little with using SRV DNS records for locating
MQTT brokers and thought others might be interested. If you have code
that supports it you can now perform a lookup à la "dig
_mqtt._tcp.mosquitto.org srv" and receive the answer that you should
connect to test.mosquitto.org:1883.

There is early code at
https://bitbucket.org/oojah/mosquitto-experimental that lets you do
this:

mosquitto_sub -h mosquitto.org -t '$SYS/#' -v -S

You can also request _mqtts._tcp.mosquitto.org or
_smqtt._tcp.mosquitto.org and get the answer test.mosquitto.org:8883.

mosquitto_sub -h mosquitto.org -t '$SYS/#' -v -S --cafile mosquitto.org.crt

Like I said, it's very early days and is broken and leaky if the
server referred to doesn't exist for example.

Cheers,

Roger

Paul Fremantle

unread,
Nov 12, 2013, 12:23:20 PM11/12/13
to mq...@googlegroups.com, ro...@atchoo.org
Roger

I think this is fantastic. It is one of the best aspects of XMPP for example. 

I think this really motivates a nicely defined URI scheme for MQTT topics that could incorporate this.

Paul

PS Bizarrely I was just talking to someone about 2 hours ago thinking about this exact idea. Unfortunately I didn't actually do anything about it!

Nicholas Humfrey

unread,
Nov 12, 2013, 12:31:55 PM11/12/13
to mq...@googlegroups.com
Very cool! Wish people would make better use of SRV records.

If web browsers supported it, we won't have this problem:
https://devcenter.heroku.com/articles/apex-domains

With an A record on root of a domain, I think it is quite arrogant to
assume HTTP is the default thing we want to do ;-)


nick.

Andy Piper

unread,
Nov 12, 2013, 5:07:02 PM11/12/13
to mq...@googlegroups.com
There are now a bunch of techniques which are described for adding this to an MQTT server, and an existing discussion in the mosquitto bug tracker :-)


Pleased to see some movement on this from Joerg and Roger independently!




--
--
To learn more about MQTT please visit http://mqtt.org

To post to this group, send email to mq...@googlegroups.com
To unsubscribe from this group, send email to
mqtt+unsubscribe@googlegroups.com

For more options, visit this group at
http://groups.google.com/group/mqtt

--- You received this message because you are subscribed to the Google Groups "MQ Telemetry Transport" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Andy Piper | Kingston upon Thames, London (UK)
blog: http://andypiper.co.uk   |   skype: andypiperuk
twitter: @andypiper  |  images: http://www.flickr.com/photos/andypiper

Dave C-J

unread,
Nov 12, 2013, 7:36:49 PM11/12/13
to mq...@googlegroups.com
Just as well I got other Andy to register here a while ago ... http://www.dns-sd.org/ServiceTypes.html

Jan-Piet Mens

unread,
Nov 13, 2013, 3:07:16 AM11/13/13
to mq...@googlegroups.com
Roger,

> I've been playing a little with using SRV DNS records for locating
> MQTT brokers and thought others might be interested.

As I mentioned to you yesterday, this is excellent! It's a shame not
more use is made of DNS SRV records.

FWIW, I've hacked up [1] preliminary support for SRV records to
mosquitto.py. Not quite sure of the full implications, but it's a start.

Keep up the great work!

-JP

[1] https://gist.github.com/jpmens/7445275

Andy Piper

unread,
Nov 13, 2013, 3:33:06 AM11/13/13
to mq...@googlegroups.com
Can you submit that as a patch to Paho Python's client (which is mosquitto Python) via Eclipse bugzilla? :-)


--
--
To learn more about MQTT please visit http://mqtt.org

To post to this group, send email to mq...@googlegroups.com
To unsubscribe from this group, send email to


For more options, visit this group at
http://groups.google.com/group/mqtt

---
You received this message because you are subscribed to the Google Groups "MQ Telemetry Transport" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Jan-Piet Mens

unread,
Nov 13, 2013, 3:39:51 AM11/13/13
to mq...@googlegroups.com
Andy,

> Can you submit that as a patch to Paho Python's client (which is mosquitto
> Python) via Eclipse bugzilla? :-)

Roger showed me the Eclipse Legal Process [1] yesterday, which is why I
put the patch in the Public Domain. ;-)

(My non-legal thinking / hope is that Roger can then just
copy/adapt/improve the code to best suit.)

-JP

[1] http://www.eclipse.org/legal/EclipseLegalProcessPoster.pdf

Jan-Piet Mens

unread,
Nov 13, 2013, 6:11:14 AM11/13/13
to mq...@googlegroups.com
Thanks to Roger for twisting my arm really really hard, I've "signed"
all the stuff, and have pushed my meager contribution for DNS SRV
support in client.py to [1].

-JP

[1] https://github.com/jpmens/paho-mqtt-dns-srv/commit/10c2ad7a224ba02f15133854187bd0a789c049bb

Roger Light

unread,
Nov 13, 2013, 4:16:23 PM11/13/13
to mq...@googlegroups.com, General development discussions for paho project
Thanks Jan-Piet,

As it's the first time I'll be taking a contribution I'll be making
sure I'm covering everything. Rest assured it'll be quicker next time!

I've cross posted to paho-dev for completeness.

Cheers,

Roger
Reply all
Reply to author
Forward
0 new messages