Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] [android.service] When I reconnect in onFailure function.The app crash.

Hi all,
When I failed to connect to mqtt server.I run into IMqttActionListener's onFailure function.Then I call below code.
String[] actionArgs = new String[0];
ActionListener acListener = new ActionListener(this.context,ActionListener.Action.CONNECT,this.clientid,actionArgs);
MqttConnectOptions connOpt = new MqttConnectOptions();
connOpt.setConnectionTimeout(Constants.MQTT_CONN_IMEOUT);
connOpt.setKeepAliveInterval(Constants.MQTT_KEEPALIVE_INTERVAL);
connOpt.setCleanSession(false);
this.mqttclient.setCallback(new MqttCallbackHandler(this.context,this.clientid));
this.mqttclient.setTraceCallback(new MqttTraceCallback());
try{
this.mqttclient.connect(connOpt,this.context, acListener);
}catch (MqttException e){
e.printStackTrace();
}
 
The app crash.the stack is
FATAL EXCEPTION: main
java.lang.OutOfMemoryError: pthread_create (stack size 16384 bytes) failed: Try again
at java.lang.VMThread.create(Native Method)
at java.lang.Thread.start(Thread.java:1029)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:913)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1306)
at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:426)
at com.example.zhangkai.gpstraker.NetWork.MqttConn.connect(MqttConn.java:55)
at com.example.zhangkai.gpstraker.NetWork.ActionListener.onFailure(ActionListener.java:155)
at org.eclipse.paho.android.service.MqttTokenAndroid.notifyFailure(MqttTokenAndroid.java:146)
at org.eclipse.paho.android.service.MqttAndroidClient.simpleAction(MqttAndroidClient.java:1374)
at org.eclipse.paho.android.service.MqttAndroidClient.connectAction(MqttAndroidClient.java:1325)
at org.eclipse.paho.android.service.MqttAndroidClient.onReceive(MqttAndroidClient.java:1265)
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:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
 
What should I in onFailure function
Thanks,
zhangkai

Back to the top