NullPointerExecption
QX-Zach opened this issue · 5 comments
E/AndroidRuntime: FATAL EXCEPTION: hawtdispatch-DEFAULT-2
Process: personal.zach.gprsdemo, PID: 18304
java.lang.NullPointerException: Attempt to invoke interface method 'boolean org.fusesource.hawtdispatch.transport.Transport.offer(java.lang.Object)' on a null object reference
at org.fusesource.mqtt.client.CallbackConnection$7.run(CallbackConnection.java:450)
at org.fusesource.hawtdispatch.transport.HeartBeatMonitor$3.run(HeartBeatMonitor.java:87)
at org.fusesource.hawtdispatch.transport.HeartBeatMonitor$1.run(HeartBeatMonitor.java:65)
at org.fusesource.hawtdispatch.internal.SerialDispatchQueue.run(SerialDispatchQueue.java:100)
at org.fusesource.hawtdispatch.internal.pool.SimpleThread.run(SimpleThread.java:77)
java.lang.NullPointerException
at org.fusesource.mqtt.codec.MQTTProtocolCodec.encode(MQTTProtocolCodec.java:70)
at org.fusesource.hawtdispatch.transport.AbstractProtocolCodec.write(AbstractProtocolCodec.java:139)
at org.fusesource.hawtdispatch.transport.TcpTransport.offer(TcpTransport.java:653)
at org.fusesource.mqtt.client.CallbackConnection.send(CallbackConnection.java:698)
at org.fusesource.mqtt.client.CallbackConnection.send(CallbackConnection.java:684)
at org.fusesource.mqtt.client.CallbackConnection.publish(CallbackConnection.java:630)
at org.fusesource.mqtt.client.CallbackConnection.publish(CallbackConnection.java:619)
The same.
Issue appears only with callback connection type
during:
nextWriteBuffer.write(digit);
nextWriteBuffer is null
@laviua I have replace this sdk with paho.mqtt.java, and it works well.
@VolodymyrCj, yes, i know )
anyway thanks for you answer
this because of the signal of wifi is not stable. mqtt will reconnect frequent,and cause the thread stack overflow.
now,i use the following settings.
mqtt.setConnectAttemptsMax(10L);
mqtt.setReconnectAttemptsMax(-1);
mqtt.setReconnectDelay(100L);
mqtt.setReconnectDelayMax(30000L);
mqtt.setReconnectBackOffMultiplier(2);
but it does't work.
You can judge the network status
And cancel the connection
你可以判断网络状态
并且取消连接