Broker auto-discovery

1,950 views
Skip to first unread message

Nicholas Humfrey

unread,
Jan 1, 2012, 12:32:11 PM1/1/12
to MQ Telemetry Transport
Hello,

I have just been thinking about broker auto-discovery - particularly for small devices that you don't want to have to individually configure each of the nodes.

Ideas:
- Zeroconf / Multicast-DNS / DNS-SD
- Anycast / a well-known IPv6 address
- DHCP option

The last option is probably the easiest for small devices - any other ideas?

Started a wiki page here:
http://mqtt.org/wiki/broker_auto-discovery


nick.

Andy Piper

unread,
Jan 1, 2012, 1:00:47 PM1/1/12
to mq...@googlegroups.com
Great stuff! I've previously suggested zeroconf and indeed proposed it as a feature for mosquitto in the past.

Would not need to be a protocol modification at all - just a broker feature for advertising the port, and the client app to use for passing to the connect() call.

from mobile

> --
> 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+uns...@googlegroups.com
>
> For more options, visit this group at
> http://groups.google.com/group/mqtt

Nicholas O'Leary

unread,
Jan 1, 2012, 1:06:47 PM1/1/12
to mq...@googlegroups.com

It's also worth adding that MQTT's little brother, MQTT-s, includes a broker/gateway discovery mechanism.

It is pretty light weight, as you'd expect, but I haven't done a sidebyside comparison with those you list.

As Andy says, brokers are free to implement any discovery system they want... Doesn't need to be part of the protocol.

Nick

Roger Light

unread,
Jan 1, 2012, 6:33:23 PM1/1/12
to mq...@googlegroups.com
On 1 Jan 2012, at 17:32, Nicholas Humfrey <n...@aelius.com> wrote:

> I have just been thinking about broker auto-discovery - particularly for
> small devices that you don't want to have to individually configure each of
> the nodes.

Like Andy said, he's reported it as a bug against mosquitto (
https://bugs.launchpad.net/mosquitto/+bug/902916 ) so I've been
thinking about this a bit myself.

I'm looking at adding zeroconf support to mosquitto, but it does vex
me somewhat that the client libraries are about 2/3 bigger than the
mosquitto executable...

On Sun, Jan 1, 2012 at 6:06 PM, Nicholas O'Leary <nick....@gmail.com> wrote:

> It's also worth adding that MQTT's little brother, MQTT-s, includes a
> broker/gateway discovery mechanism.

Sounds good. I've got the MQTT-S protocol pdf printed out - I will get
round to reading it one of these days.

Cheers,

Roger

James Wilcox

unread,
Feb 9, 2012, 9:12:59 AM2/9/12
to MQ Telemetry Transport
Hello,

Independently I have also been looking at combining service discovery
with the mosquitto broker (for small devices that would require auto
configuration) and have only just come across this group.

I played around with the source for mosquitto and came up with a
working example. One that adds a -a / --avahi command line option.
When given the command line argument mosquitto will fork() and execl()
a avahi-publish-service process (http://linux.die.net/man/1/avahi-
publish-service). The listening port information is acquired from
config->listeners[0].port so that the service is always advertised
with the correct port. The avahi-publish-service is killed when
mosquitto returns which has the effect of removing the service
advertisement. The modification works well and advertises the MQTT
broker using avahi on the specified port when ever mosquitto is
running.

Now I realise that this is probably a pretty ugly hack but it does
what I need. I had considered simply copying in a *.service file into /
etc/avahi/services/ like the launchpad thread suggests you can but
felt modifying the source gave me more options i.e ports.

I won't bother posting the modified source as the changes are likely
trivial to most others in the group (this was my first attempt at
modifying a program source) but what I would like to know is if anyone
has made any progress on achieving this more elegantly.

Thanks,

James.

Roger Light

unread,
Feb 9, 2012, 9:30:14 AM2/9/12
to mq...@googlegroups.com
Hi James,

That sounds like an interesting approach which I'd not considered
myself. Glad to hear you got it working for yourself.

I think the correct approach here is to use a library provided by e.g.
avahi. It's not even all that difficult - I've got some code written
to do it that's not quite complete. The reason I haven't done more is
because it's important that it is a cross platform solution and also
because I'm not sure how the user interface should appear for the
clients. Is a -a option on the clients sufficient? I don't know.

Cheers,

Roger

Reply all
Reply to author
Forward
0 new messages