MQTT peer-to-peer style, broker & client on the same machine?

2,023 views
Skip to first unread message

Jerzy

unread,
Jul 7, 2014, 4:36:02 AM7/7/14
to mq...@googlegroups.com
Hello!

I would like to create a local HA system without a central hub, using Raspberry Pi devices. It should be accessible only in my home WLAN and it will consist of a few RPi sensors (always on) and mobile apps (run once in a time). The sensors will measure and store some values, then they should send the values on demand using MQTT to the client apps on smartphones. I don't want any other devices involved, no external hub/broker, just P2P style. I was thinking about installing an MQTT server and a client on the same RPi machine. Is this how it should be done? What if there will be many MQTT servers in the same WLAN? Will clients automatically discover the designated broker?

Thanks!

Roger Light

unread,
Jul 8, 2014, 5:49:12 AM7/8/14
to mq...@googlegroups.com
Hi Jerzy,

You could do this using a server that supports bridging. This means
that the server can connect to another server, acting as a client.

Each Pi would bridge to all other Pis and send only the data that it
has received from the sensors. Your client app could then connect to
any of the Pis and receive all of the information.

Using mosquitto config file syntax as an example:

# On Pi1, which collects sensor data for the kitchen
connection To_Pi2
address 192.168.0.12
topic sensors/kitchen/# out

connection To_Pi3
address 192.168.0.13
topic sensors/kitchen/# out

# On Pi2, which collects sensor data for the garden
connection To_Pi1
address 192.168.0.11
topic sensors/garden/# out

connection To_Pi3
address 192.168.0.13
topic sensors/garden/# out

Cheers,

Roger
> --
> To learn more about MQTT please visit http://mqtt.org
> ---
> You received this message because you are subscribed to the Google Groups
> "MQTT" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mqtt+uns...@googlegroups.com.
> To post to this group, send email to mq...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mqtt.
> For more options, visit https://groups.google.com/d/optout.

Adam Renner

unread,
Jul 8, 2014, 10:22:43 PM7/8/14
to mq...@googlegroups.com

I am not sure that MQTT is the best thing here. It is designed to decouple producers and consumers of data. You mention that you want "values on demand", so something that is more of a request-response type of thing might be a better fit?

For discovery of services on the local network, you might want to look into zeroconf and Avahi for your RasPis and Bonjour for Apple products.

TGit Tech

unread,
Dec 27, 2017, 2:15:17 AM12/27/17
to MQTT
I too am running into the same bottleneck with MQTT - as it seems from a simple internet search of P2P with MQTT that many others are seeing this same glaring defect of this growing popular 'IoT' protocol standard.  While currently investigating other protocols like CANopen, LwM2M ( too heavy ), and Modbus it just seems to me that an efficient 'Client' side standard has never been made and especially for any P2P client support mixed with MQTT. 

If anyone has any solutions to this problem short of "Current MQTT is only a half-solution" to the fragmentation of IoT standardizing - I'd love to hear it.
Reply all
Reply to author
Forward
0 new messages