paho.mqtt.android
paho.mqtt.android copied to clipboard
getSessionPresent on MqttTokenAndroid results in a null pointer exception
From @gholadr on March 9, 2016 4:21
This just doesnt work
@Override
public void onSuccess(IMqttToken asyncActionToken) {
// We are connected
Log.d(TAG, "onSuccess");
if(asyncActionToken == null){
Log.d(TAG, "asyncActionToken is null");
}
else{
Log.d(TAG, "session present? " + asyncActionToken.getSessionPresent());
}
}
is this partially implemented? I tried with version 1.0.2
Copied from original issue: eclipse/paho.mqtt.java#175
@gholadr 1.0.2 is quite old at this point and we are rapidly coming up to a new release in May (Eclipse Neon). Could you try the 1.0.3 Snapshot to see if the bug still exists there please? We're also moving repository at the moment, 1.0.2 will remain in the Java repository, but 1.0.3 (soon to be 1.2) is now hosted here: https://github.com/eclipse/paho.mqtt.android
You can try the Snapshot version by changing your maven repository to: https://repo.eclipse.org/content/repositories/paho-snapshots/ and then changing your dependencies to:
org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.3-SNAPSHOT org.eclipse.paho:org.eclipse.paho.android.service:1.0.3-SNAPSHOT
From @gholadr on April 25, 2016 6:36
@jpwsutton I've tried as you suggested above with 1.0.3-SNAPSHOT. I still get the same runtime exception. java.lang.NullPointerException: Attempt to invoke interface method 'boolean org.eclipse.paho.client.mqttv3.IMqttToken.getSessionPresent()' on a null object reference
I've added the code to this github repository
The full stacktrace
java.lang.NullPointerException: Attempt to invoke interface method 'boolean org.eclipse.paho.client.mqttv3.IMqttToken.getSessionPresent()' on a null object reference
at org.eclipse.paho.android.service.MqttTokenAndroid.getSessionPresent(MqttTokenAndroid.java:244)
at co.ghola.pushmq4.BackgroundService$2.onSuccess(BackgroundService.java:108)
at org.eclipse.paho.android.service.MqttTokenAndroid.notifyComplete(MqttTokenAndroid.java:124)
at org.eclipse.paho.android.service.MqttAndroidClient.simpleAction(MqttAndroidClient.java:1503)
at org.eclipse.paho.android.service.MqttAndroidClient.connectAction(MqttAndroidClient.java:1445)
at org.eclipse.paho.android.service.MqttAndroidClient.onReceive(MqttAndroidClient.java:1374)
at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Still not working?