An MQTT broker can be instructed to retain messages published to a topic. Message retention comes in two flavors, known as retained messages and durable connections:
- A retained message is where the broker retains the last message published on a topic. This is also commonly referred to as the last known good message, and any client subscribing to a topic automatically gets this message.
- Durable connections are also about retaining messages but in a different context. If a client tells the broker it wants a durable connection, then the broker retains QoS 1 and 2 messages for that client while it's offline.
Unless configured specifically, Mosquitto does not retain messages or connections across server restarts. To persist this information across a restart, a Mosquitto configuration file must contain the entry persistence true. A default installation of Mosquitto on a Raspberry Pi should include...