paho.mqtt.android icon indicating copy to clipboard operation
paho.mqtt.android copied to clipboard

NULL Pointer Exception

Open yuvisiva opened this issue 7 years ago • 7 comments

This Exception is Occured when My Internet connection is Switched OFF and ON. Frequently happening

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void java.util.Timer.cancel()' on a null object reference org.eclipse.paho.client.mqttv3.MqttAsyncClient.stopReconnectCycle (MqttAsyncClient.java:1120) org.eclipse.paho.client.mqttv3.MqttAsyncClient.reconnect (MqttAsyncClient.java:1057) org.eclipse.paho.android.service.MqttConnection.reconnect (MqttConnection.java:1049) org.eclipse.paho.android.service.MqttService.reconnect (MqttService.java:342) org.eclipse.paho.android.service.MqttService$NetworkConnectionIntentReceiver.onReceive (MqttService.java:827)

yuvisiva avatar May 05 '17 06:05 yuvisiva

Are you on mqttv3:1.1.0? For me switching to paho.client.mqttv3:1.1.1 eliminated the problem.

algrid avatar May 08 '17 10:05 algrid

Yes. Ill check with newer version. Gradle is not highlighting the version changes. That's why I did not know about this update.

yuvisiva avatar May 08 '17 11:05 yuvisiva

I have the same problem, this is the stack trace:

Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4000010 (has extras) } in org.eclipse.paho.android.service.MqttService$NetworkConnectionIntentReceiver@1c954746 at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:924) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5660) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758) Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void java.util.Timer.cancel()' on a null object reference at org.eclipse.paho.client.mqttv3.MqttAsyncClient.stopReconnectCycle(MqttAsyncClient.java:1120) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.reconnect(MqttAsyncClient.java:1057) at org.eclipse.paho.android.service.MqttConnection.reconnect(MqttConnection.java:1049) at org.eclipse.paho.android.service.MqttService.reconnect(MqttService.java:342) at org.eclipse.paho.android.service.MqttService$NetworkConnectionIntentReceiver.onReceive(MqttService.java:827) at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:914) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5660) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963)

s-shalabi avatar May 21 '17 10:05 s-shalabi

@quadkastsiva "Are you on mqttv3:1.1.0? For me switching to paho.client.mqttv3:1.1.1 eliminated the problem." is it solve your problem?

omarhayatsatti avatar Aug 25 '17 04:08 omarhayatsatti

am also get same problem so i changed version paho.client.mqttv3:1.1.1 ,but i got connect lost issues, My client MqttAndroidClient and am using (wss) can any one help me

rajeshkanna777 avatar Nov 28 '17 16:11 rajeshkanna777

This issue is occur in mqttv3:1.1.0. However, I can not reproduce this issue in mqttv3:1.1.1

hoanglm4 avatar May 14 '18 17:05 hoanglm4

I have the same problem with mqttv3:1.2.1...

acaliaro avatar Jan 14 '20 08:01 acaliaro