简体   繁体   中英

MQTT RaspberryPi Broker

I have a small doubt about using MQTT in my project. I just wanted to know if it is possible that I use RaspberryPi as MQTT broker (server) to receive data from a device which is publishing in MQTT and then at the same time this RaspberryPi publishes the same data in MQTT to another subscriber? If it is possible, then what would be the message broker in the second part? I mean, I want the RaspberryPi to be the device controller(to act on the device data) and at the same time to publish the data to another MQTT subscriber. Is this possible?

Thank you so much, Pouya

Pub/sub protocols like MQTT support a one to many approach to data delivery. The broker is the central distribution point for data can handle many different clients.

When a client published a message the broker will deliver that message to all clients that have subscribed to the topic that message is published to.

You can run multiple clients on the same machine each publishing, subscribing or both at the same time

Actually, this is what MQTT do!

If Device A (Publisher) publish a message in a Topic say: pi-topic/xxxx to MQTT Broker running in Raspberry Pi.Then you just make you Device B (Subscriber) to subscribe/listen to the same topic ie pi-topic/xxxx .In this way, you can achieve it.You can use any library like Paho.

You need to read further about PUB-SUB models and Queue mechanism .It will help in future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM