I am trying to create an mqtt client in my android service using the paho client library . The mosquitto broker is running on my local machine. I am getting an MqttPersistenceException exception when i try to create a new instance of the MQTTClient.
//create client port=1883 mqttConnSpec="tcp://"+ipaddressOflocalMachine+":"+ port mqttClient = new MqttClient(mqttConnSpec, mqttClientId)
the exception does not give any reason. I am successfully able to communicate using a java console app. Is there something extra needed when running this in the android emulator. Any help is much appreciated
thanks Ben
Can you share a little more of your code - are you setting up an persistence class?
There are a number of good resources which discuss Java/Paho MQTT clients on Android. The basic thing is that you do need to implement a persistence class or specify the in-memory or file one provided. This was discussed in another StackOverflow answer. Also see this "bug" which explains that you need to ensure that user.dir is set or use a different persistence method. There is a list of additional resources on the MQTT wiki.