Open oreillymj opened 3 years ago
Hi,
I have the same issue with mqtt-paho 5 library:
Exception occurred while publishing workspace update event; reason=32109; msg='Connection lost' org.eclipse.paho.mqttv5.common.MqttException: Connection lost at org.eclipse.paho.mqttv5.client.internal.CommsReceiver.run(CommsReceiver.java:196) ~[org.eclipse.paho.mqttv5.client-1.2.5.jar:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312] Caused by: javax.net.ssl.SSLException: Connection reset at sun.security.ssl.Alert.createSSLException(Alert.java:127) ~[?:1.8.0_312] at sun.security.ssl.TransportContext.fatal(TransportContext.java:324) ~[?:1.8.0_312] at sun.security.ssl.TransportContext.fatal(TransportContext.java:267) ~[?:1.8.0_312] at sun.security.ssl.TransportContext.fatal(TransportContext.java:262) ~[?:1.8.0_312] at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1563) ~[?:1.8.0_312] at sun.security.ssl.SSLSocketImpl.access$400(SSLSocketImpl.java:73) ~[?:1.8.0_312] at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:973) ~[?:1.8.0_312] at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:864) ~[?:1.8.0_312] at java.io.DataInputStream.readByte(DataInputStream.java:265) ~[?:1.8.0_312] at org.eclipse.paho.mqttv5.client.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:96) ~[org.eclipse.paho.mqttv5.client-1.2.5.jar:?] at org.eclipse.paho.mqttv5.client.internal.CommsReceiver.run(CommsReceiver.java:139) ~[org.eclipse.paho.mqttv5.client-1.2.5.jar:?] ... 1 more Suppressed: java.net.SocketException: Connection reset by peer: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) ~[?:1.8.0_312] at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111) ~[?:1.8.0_312] at java.net.SocketOutputStream.write(SocketOutputStream.java:155) ~[?:1.8.0_312] at sun.security.ssl.SSLSocketOutputRecord.encodeAlert(SSLSocketOutputRecord.java:81) ~[?:1.8.0_312] at sun.security.ssl.TransportContext.fatal(TransportContext.java:355) ~[?:1.8.0_312] at sun.security.ssl.TransportContext.fatal(TransportContext.java:267) ~[?:1.8.0_312] at sun.security.ssl.TransportContext.fatal(TransportContext.java:262) ~[?:1.8.0_312] at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1563) ~[?:1.8.0_312] at sun.security.ssl.SSLSocketImpl.access$400(SSLSocketImpl.java:73) ~[?:1.8.0_312] at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:973) ~[?:1.8.0_312] at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:864) ~[?:1.8.0_312] at java.io.DataInputStream.readByte(DataInputStream.java:265) ~[?:1.8.0_312] at org.eclipse.paho.mqttv5.client.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:96) ~[org.eclipse.paho.mqttv5.client-1.2.5.jar:?] at org.eclipse.paho.mqttv5.client.internal.CommsReceiver.run(CommsReceiver.java:139) ~[org.eclipse.paho.mqttv5.client-1.2.5.jar:?]
It happens when I plug out the network cable or disable network interface for example "ifconfig eth0 down"
I also encountered the same problem. Can someone help me solve it or point out the direction? Exceptions : Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197) at java.lang.Thread.run(Thread.java:919) Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:270) at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92) at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137) ... 1 more
Please fill out the form below before submitting, thank you!
I still see this issue from version 1.11, 1.2.0, and now 1.2.5. It never seems to have been fixed correctly.
2021-07-07 07:52:28.879 11703-11703/com.example.paho_125_test I/MQTTService: startKeepAlives()->start 2021-07-07 07:52:28.886 11703-11703/com.example.paho_125_test I/MQTTService: startKeepAlives()->rescheduled keepalive 2021-07-07 07:52:28.886 11703-11703/com.example.paho_125_test I/MQTTService: startKeepAlives()->KEEP_ALIVE UUID sent=0b134bc5-71d4-40ee-bb7e-e6c30bc43966 2021-07-07 07:52:28.886 11703-11703/com.example.paho_125_test I/MQTTService: startKeepAlives()->KEEP_ALIVE Interval sent=10000 2021-07-07 07:52:28.886 11703-11703/com.example.paho_125_test I/MQTTService: startKeepAlives()->end 2021-07-07 07:55:55.142 11703-25488/com.example.paho_125_test E/MQTTService: connectionLost()->start 2021-07-07 07:55:55.160 11703-25488/com.example.paho_125_test E/MQTTService: connectionLost()->Cause= Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197) at java.lang.Thread.run(Thread.java:919) Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:270) at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92) at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137) at java.lang.Thread.run(Thread.java:919) 2021-07-07 07:55:55.162 11703-25488/com.example.paho_125_test E/MQTTService: connectionLost()->end
See https://github.com/eclipse/paho.mqtt.java/issues/673 and https://github.com/eclipse/paho.mqtt.java/issues/679
Wired connections work fine, but it seems the variability of wifi on Android may be the underlying cause. Just my theory. My attempts to apply the fix in https://github.com/eclipse/paho.mqtt.java/issues/673 cause high CPU usage on Android.
Changing lines 137 in CommsReceiver as follows
MqttWireMessage message = null; synchronized (lifecycle) { if (in.available>0){ message = in.readMqttWireMessage(); } current_state = State.RUNNING; }
Would appear to fix the issue, but the affect on the while{} loop seems to trigger constant high CPU in the Android studio profiler.
Not sure if this change in MqttInputStream would have a similar high CPU affect.
Testing a fix for this issue requires leaving Android code running for 24hrs as it specifically seems to occur overnight during low device usage.
BTW - The default socket timeout of 1s may be too small for Android on Wifi. I'm currently testing 1600ms to see if it fixes the issue. Other have bumped there socket timeout value to 5s.
https://stackoverflow.com/questions/30378288/android-socket-connection-timeout