Closed timtay-microsoft closed 5 years ago
Here is the simplest repro of the issue that I could make:
String broker = "wss://iot.eclipse.org:443";
String clientId = "JavaSample";
MemoryPersistence persistence = new MemoryPersistence();
try {
MqttClient sampleClient = new MqttClient(broker, clientId, persistence);
sampleClient.setCallback(new MqttCallback()
{
@Override
public void connectionLost(Throwable cause) {
System.out.println("Lost connection");
cause.printStackTrace(); //EOFException thrown here within a few seconds
}
@Override
public void messageArrived(String topic, MqttMessage message) throws Exception {
}
@Override
public void deliveryComplete(IMqttDeliveryToken token) {
}
});
System.out.println("Connecting to broker: "+broker);
sampleClient.connect();
System.out.println("Connected");
} catch(MqttException me) {
me.printStackTrace();
}
while (true)
{
//Just wait for connectionLost callback to happen
}
I have seen this bug as well. FWIW, reverting to 1.2.0 seems to fix the bug.
same here!
same. any solutions?
the issue seems because of the read time out of socket. i solve its problem in pull request 684 also you can get my fork in the link below: https://github.com/siavashsoleymani/paho.mqtt.java
you can set the soTimeout property in ConnectOptions to 0 for infinite read timeout or you can set a value based on your system requirements.
Same problem here.
@icraggs this is a big blocker for me, is any work being done to fix this issue? And are there any plans to put out a new release with that fix?
Yes, I'm starting to look at it now. I've been making a new release of the C client as well as MQTT V5 support. I think this will need some new tests.
Thanks for getting the fix into the dev branch, @icraggs ! When can I expect a release with this fix?
@icraggs pinging on this, I would really appreciate an ETA on the release of this fix
@timtay-microsoft if you're in a hurry your best bet is to pull the develop branch and build the .jar file yourself, until version 1.2.2 is released.
I'll look into getting out a release next week.
1.2.2 release created
Thanks, icraggs!
Still getting EOF exception on v1.2.2:
Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:190)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:270)
at t.a.a.a.a.a.s.f.b(MqttInputStream.java:92)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:137)
at java.lang.Thread.run(Thread.java:919)
@ishaansrm This issue is already fixed. May be you are getting same error but due to some other code issue.
Could you please open a new issue with details of your use/test case and any detail you can provide to help with debugging the issue.
Sorry false alarm, the issue was due to some other issues not related to the lib
@ishaansrm what was your error from? i am having the same issue and maybe it is something similar
Well, my mqtt was accidentally pointing to a staging broker, which was offline.
You might want to check the broker endpoint & then see if the broker is up & running & what data that's receiving.
@ishaansrm do you have an example for this loop, "check the broker endpoint & then see if the broker is up & running & what data that's receiving"?
My problem is that i have a broker that works all day, and at night it is getting closed. In the morning when it gets started, my android app tries to reconnect to it with success. But after this every keepAlive * 1.5 seconds the android app gets "lost connection" and reconnects to the broker after 1-2 seconds. I think this issue disappear after I interact with the android tablet.
2020-04-29 09:23:27.425 W/MQTT - disconnected: Connection lost (32109) - java.io.EOFException 2020-04-29 09:23:27.425 W/MQTT - disconnected: [Ljava.lang.StackTraceElement;@a29afb6 2020-04-29 09:23:27.427 W/MQTT - disconnected: 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:764) 2020-04-29 09:23:27.427 W/MQTT - disconnected: Connection lost 2020-04-29 09:23:28.433 D/NetworkManagementSocketTagger: tagSocket(76) with statsTag=0xffffffff, statsUid=-1 2020-04-29 09:23:28.706 D/TAGG(run always): in timer ++++ 0 2020-04-29 09:23:28.706 D/SUPREM: 0 {} 2020-04-29 09:23:29.298 D/AlarmPingSender: Register alarmreceiver to MqttServiceMqttService.pingSender.paho153573459046727 2020-04-29 09:23:29.306 D/AlarmPingSender: Schedule next alarm at 1588141509306 2020-04-29 09:23:29.306 D/AlarmPingSender: Alarm scheule using setExactAndAllowWhileIdle, next: 100000 2020-04-29 09:23:29.316 W/MQTT - connected: tcp://10.80.1.150:1883 recc true
2020-04-29 09:25:59.994 W/MQTT - disconnected: Connection lost (32109) - java.io.EOFException 2020-04-29 09:25:59.994 W/MQTT - disconnected: [Ljava.lang.StackTraceElement;@9ed1f45 2020-04-29 09:25:59.995 W/MQTT - disconnected: 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:764) 2020-04-29 09:25:59.995 W/MQTT - disconnected: Connection lost 2020-04-29 09:26:01.003 D/NetworkManagementSocketTagger: tagSocket(76) with statsTag=0xffffffff, statsUid=-1 2020-04-29 09:26:01.847 D/AlarmPingSender: Register alarmreceiver to MqttServiceMqttService.pingSender.paho153573459046727 2020-04-29 09:26:01.861 D/AlarmPingSender: Schedule next alarm at 1588141661861 2020-04-29 09:26:01.861 D/AlarmPingSender: Alarm scheule using setExactAndAllowWhileIdle, next: 100000 2020-04-29 09:26:01.874 W/MQTT - connected: tcp://10.80.1.150:1883 recc true
Problem Description:
I need to test a large number of clients to link my mqttbroker, so I create 5000 or 10000 mqtt clients, or more, in a loop with a certain number of threads. When the number is less than 4000, the link is normal, sometimes when the number is more than 3000-4000. The same problem will arise.
The exception information is as follows:
2021-03-12 17:35:53 [ERROR] MqttException,CONNECTION_LOST !!! sn SKYWAY0004057644 ,线程是 pool-1-thread-105 已断开连接 (32109) - java.io.IOException: Connection is lost. at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:197) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.IOException: Connection is lost. at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:172) ... 1 more
At the same time, I tried to use Version 1.2.1. Or 1.2.4. Still get the same Error.
I am using
'com.github.hannesa2:paho.mqtt.android:4.2'
and i am still seeing this issue. But in my case it is somehow related to the keepAliveInterval
in MqttConnectOptions()
.
I kept keepAliveInterval to 10 seconds, and if my app is not publishing
anything for 10 seconds, then I was getting this EOFException
. I increased it to 100 seconds and it worked fine.
Hope this helps resolving the issue further
@gitusman were you able to solve this by anymeans
Please fill out the form below before submitting, thank you!
Upgrading from version 1.2.0 to 1.2.1 appears to introduce a regression on issue #358
Connection appears to be established successfully, but connection is lost shortly afterwards with a stacktrace like
The issue repro's consistently, and affects any WSS connections that I try.
server uri looks like: "wss://mywebsite.net/$iothub/websocket" and the mqtt connection options are all the default values.