Reputation: 18175
I have feeling that my client not sets "retain" message flag. Is ti possible somehow get list of retained messages in Mosquitto MQTT broker? How?
Upvotes: 1
Views: 5116
Reputation: 90
With mosquitto version 2.0.14 MQTT v5.0/v3.1.1/v3.1 broker, you can get a list of retained messages via:
$ mosquitto_sub -u user -P pass -t "#" -v --retained-only
Upvotes: 1
Reputation: 59608
When the message is received by a client it will have the retained bit set in the header, so you should be able to check from any client, how you do that will depend on the client library you are using.
Depending on what rate the client is publishing messages (e.g. there is a long enough gap between messages) you could just use the mosquitto_sub
command to check. If you know when the last time the client published just wait until afterwards and then subscribe with the command line tool, if it prints a message immediately then there was a retained message.
The other option is to examine the mosquitto persistence database, included in the source code in the src/db_dump
directory there is a tool to walk the content of the database. Retained messages should get written to the database so should allow you check. I don't think the tool is build and included in any of the binary install packages so you will have to build it yourself.
Upvotes: 2