4

I want to understand the persistence related options in Mosquitto as described here.

To begin with, do these options apply only in case of QoS > 0 and/or retained messages?

  • persistence

If true, connection, subscription and message data will be written to the disk in mosquitto.db at the location dictated by persistence_location.

What is the meaning of 'message data' - the actual payload? Only when retained or otherwise as well?

  • persistence_location

If not given, then the current directory is used.

What is the current directory relative to?

2

Messages are persisted if

  • they are retained
  • while inflight and waiting to be acknowledged, QOS 1/2
  • QOS 1/2 waiting to be delivered to an offline client that held a subscription to the topic before going offline
  • Same as previous for QOS 0 messages if the queue_qos0_messages is set to true

The whole message is stored in memory and sync'd to disk at regular intervals (controlled by the autosave_interval option) or when the broker shuts down to ensure data is not lost.

As with all processes the current directory is the location where where the process was started e.g. if your shell is in your home directory /home/user when you run mosquitto then the current directory will be your home directory. When mosquitto is run as a service this will probably be / in which case the mosquitto user would not have permission to write there. It is always better to be explicit where to write logs and persistence data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.