Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Persistence (C Language)

Hi Jaspar,

when you use the MQTTCLIENT_PERSISTENCE_DEFAULT persistence option, the persistence_context should be set to a directory to use.  That's it.  The persistence capability is all done for you, you don't need to make any calls to the persistence layer yourself.

The MQTTCLIENT_PERSISTENCE_USER option is provided if you want to use another persistence library.  Here is an example of using Redis (  In that case, you would implement the persistence interface, but you still wouldn't make the actual calls yourself, that would still be done by the Paho library.

I hope that is a good explanation.


On 12/30/2016 10:29 AM, Jaspar Löchte wrote:
Hello there,

I don’t know, if this is the “right” place to get help for using MQTT Paho.

I am doing some research on persistent messaging with MQTT. I use the open source Mosquitto Broker in combination with MQTT-Paho for C language.

I just set up a publisher (able to publish various messages on a topic) and a subscriber (to receive them).

Now I wanted to get persistence mode. I tried to figure out how to use the functions from the MQTTClientPersistence.h Header.

There is no example for using persistence header. I thought I need to use the client, then I thought about a void pointer.
The other thing I am not sure about is, what to use as a persistence type?
If I use MQTTCLIENT_PERSISTENCE_DEFAULT the paho script is doing everything for me and I dont need to open an own PersistenceClient? And for MQTTCLIENT_PERSISTENCE_USER I need to set up everything on my own? (with opening, and saving messages and all the stuff?)

What ever I try, I get SIGSEGV in the Persistence_open function.

void* handle;
MQTTClient client;
MQTTClient_persistence persist;
MQTTClient_create(&client, config->host, config->cid, MQTTCLIENT_PERSISTENCE_DEFAULT, dir);

// some connection options …

//persist.popen((void**)&handle, config->cid, config->host, dir);
persist.popen(&client, config->cid, config->host, dir);

Thank you

Jaspar Löchte
paho-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Ian Craggs
icraggs@xxxxxxxxxx                 IBM United Kingdom
Paho Project Lead; Committer on Mosquitto

Back to the top