Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection lost (32109) - EOFException after connect for Websocket connection #679

Closed
1 of 3 tasks
timtay-microsoft opened this issue Jun 17, 2019 · 24 comments
Closed
1 of 3 tasks
Assignees
Milestone

Comments

@timtay-microsoft
Copy link

Please fill out the form below before submitting, thank you!

  • Bug exists Release Version 1.2.1 ( Master Branch)
  • Bug exists in MQTTv3 Client on Snapshot Version 1.2.1-SNAPSHOT (Develop Branch)
  • Bug exists in MQTTv5 Client on Snapshot Version 1.2.1-SNAPSHOT (Develop Branch)

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

com.microsoft.azure.sdk.iot.device.exceptions.ProtocolException: Mqtt connection lost
	at com.microsoft.azure.sdk.iot.device.transport.mqtt.exceptions.PahoExceptionTranslator.convertToMqttException(PahoExceptionTranslator.java:75)
	at com.microsoft.azure.sdk.iot.device.transport.mqtt.Mqtt.connectionLost(Mqtt.java:366)
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.connectionLost(CommsCallback.java:303)
	at org.eclipse.paho.client.mqttv3.internal.ClientComms.shutdownConnection(ClientComms.java:439)
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:189)
	at java.lang.Thread.run(Thread.java:748)
Caused by: Connection lost (32109) - java.io.EOFException
	... 2 more
Caused by: java.io.EOFException
	at java.io.DataInputStream.readByte(DataInputStream.java:267)
	at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92)
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:136)
	... 1 more

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.

@timtay-microsoft
Copy link
Author

timtay-microsoft commented Jun 17, 2019

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
}

@windbender
Copy link

I have seen this bug as well. FWIW, reverting to 1.2.0 seems to fix the bug.

@siavashsoleymani
Copy link

same here!

@OfekRegev
Copy link

same. any solutions?

siavashsoleymani added a commit to siavashsoleymani/paho.mqtt.java that referenced this issue Jul 6, 2019
…e is 1000 that bring connection issue described in issue eclipse#679

Signed-off-by: siavash.solimaniii <siavash.solimanii@yahoo.com>
@siavashsoleymani
Copy link

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.

@CreateChance
Copy link

Same problem here.

siavashsoleymani added a commit to siavashsoleymani/paho.mqtt.java that referenced this issue Jul 25, 2019
@timtay-microsoft
Copy link
Author

@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?

@icraggs
Copy link
Collaborator

icraggs commented Aug 22, 2019

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.

@icraggs icraggs added the bug label Aug 22, 2019
@icraggs icraggs added this to the 1.2.2 milestone Aug 22, 2019
@icraggs icraggs self-assigned this Aug 22, 2019
@timtay-microsoft
Copy link
Author

Thanks for getting the fix into the dev branch, @icraggs ! When can I expect a release with this fix?

@timtay-microsoft
Copy link
Author

@icraggs pinging on this, I would really appreciate an ETA on the release of this fix

@JacquesSmuts
Copy link

@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.

@icraggs
Copy link
Collaborator

icraggs commented Sep 13, 2019

I'll look into getting out a release next week.

@icraggs
Copy link
Collaborator

icraggs commented Sep 23, 2019

1.2.2 release created

@icraggs icraggs closed this as completed Sep 23, 2019
@timtay-microsoft
Copy link
Author

Thanks, icraggs!

christophersmith added a commit to christophersmith/summer-mqtt that referenced this issue Jan 11, 2020
Updated to Paho 1.2.2 and increased sleep time to allow
for Paho TCPNetworkModule to register the SO Timeout.
Underlying issue resolved by eclipse/paho.mqtt.java#679.
Closes #2.
@ishaansrm
Copy link

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) 

@rdasgupt
Copy link
Contributor

rdasgupt commented Apr 6, 2020

@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.

@ishaansrm
Copy link

Sorry false alarm, the issue was due to some other issues not related to the lib

@cristieu9797
Copy link

@ishaansrm what was your error from? i am having the same issue and maybe it is something similar

@ishaansrm
Copy link

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.

@cristieu9797
Copy link

@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"?

@cristieu9797
Copy link

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

@SZMOFEI
Copy link

SZMOFEI commented Mar 12, 2021

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
image

At the same time, I tried to use Version 1.2.1. Or 1.2.4. Still get the same Error.

@gitusman
Copy link

gitusman commented Dec 5, 2023

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

@Navaneshwar-Reddy
Copy link

@gitusman were you able to solve this by anymeans

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests