Communicating over MQTT
Message Queue Telemetry Transport (MQTT) is a many-to-many communication protocol with a message broker as the mediator. There are publishers that send messages to the topics on the broker, and there are subscribers that receive messages from the topics that they subscribe to. A node can be a publisher and subscriber at the same time:
Figure 6.6: MQTT communication model
For MQTT, TCP is the underlying transport protocol and TLS can be configured for communication security.
Let’s see how MQTT works with a simple example. The goal in this example is to publish sensor data to an MQTT broker running in the local network and control the sensor features remotely by connecting to the broker with an MQTT client running on another machine. As listed in Technical requirements, the broker is Mosquitto. We begin with installing the broker.
Installing the MQTT broker
The mosquitto
installation package comes with an MQTT broker, a publisher...