Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] Persistence already in use error from mqtt


are you by any chance using Android?  You need to set the directory where the persistence will be stored to a writeable location.  The default is ".".


On 07/02/14 12:28, ratnopam chakrabarti wrote:
I am getting the following exception from the mqtt broker when I am trying to create a new MqttClient. The error is here ---
 Caused by: Persistence already in use (32200) at [mqtt-client-0.4.0.jar:] at org.eclipse.paho.client.mqttv3.MqttAsyncClient.( [mqtt-client-0.4.0.jar:] at org.eclipse.paho.client.mqttv3.MqttClient.( [mqtt-client-0.4.0.jar:] at org.eclipse.paho.client.mqttv3.MqttClient.( [mqtt-client-0.4.0.jar:] at [classes:] at [classes:] ... 44 more
Here is the code for my java class receive() method from where I am trying to connect to mqtt ---
MqttClient subClient = null;
    try {
        subClient = mqttHandler.createClient(userId, brokerURL);
        MQTTNotificationSubscriber notificationSub = new MQTTNotificationSubscriber(mqttHandler);

        mqttHandler.subscribe(subClient, userId);
        // do something here
    } catch (Exception e) {
        logger.error("Error in receive " + e.getMessage());

        throw new VirtualAssistServicesException(e.getMessage(), e);
    }  finally {
        try {
        } catch (MqttException e) {
            throw new VirtualAssistServicesException(e.getMessage(), e);
And here is the MQTTHandler class createClient() method ---
    MqttClient subClient = null;

    try {
        subClient = new MqttClient(brokerURL, clientId);

    } catch (MqttException e) {

When I create the client for a userId first time it works. From second time onwards when I use the same client Id it fails with the above exception. I am using clean-session=false here on purpose. 
If anyone has any idea please let me know. Thanks.

paho-dev mailing list

Back to the top