[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [paho-dev] NPE @ MqttAndroidClient.subscribe ()
|
Hi,
Because connect is asynchronous, and the connection may not established the time you call subscribe.
you should either waitForCompletion or call subscribe in IMqttActionListener.onSuccess, if you are using IMqttToken connect(MqttConnectOptions options, Object userContext, IMqttActionListener callback)
And i think we need some improvements in this case to throw a reasonable exception instead of NPE .
Best Regards,
Bin Zhang(张斌)
--------------------------------------------------------------------------------------------
WebSphere MQ, IBM China Software Development Lab
Notes: Bin BJ Zhang/China/IBM
E-Mail: zhbinbj@xxxxxxxxxx
Address: Ring Building 3F, ZhongGuanCun Software Park,
DongBeiWang West Road No.8, Haidian District, Beijing, 100193, China
-------------------------------------------------------------------------------------------
ravi lakhotia ---11/09/2014 06:39:31 AM---Hi , I am using Paho Android Service jar. In my Main Activity on onClick event
From: ravi lakhotia <ravilakhotia2006@xxxxxxxxx>
To: General development discussions for paho project <paho-dev@xxxxxxxxxxx>
Date: 11/09/2014 06:39 AM
Subject: [paho-dev] NPE @ MqttAndroidClient.subscribe ()
Sent by: paho-dev-bounces@xxxxxxxxxxx
Hi ,
I am using Paho Android Service jar. In my Main Activity on onClick event of button, I have implemented following steps:
Created Android Client, set the callback and options
Android client connect method
waitforCompletion on token from connect()
subscribe() on the same client.
getting NPE on MqttAndroidClient.subscribe() when dont have waitforCompletion call between connect and subscribe.
try {
client.connect(options, null, callback);
client.subscribe(topic,qos);
} catch (MqttException e) {
e.getCause();
}
Could not figure out what exactly is going wrong. Can someone please help on this issue ?
thanks
--
Ravi Prakash Lakhotia
_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/paho-dev
