Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] MQTT Connection Lost Error

Hi Ian,

The mosquitto log shows something like the following ---

1394531708: New connection from 192.133.12.45 on port 1990.
1394531708: Client Driver1 already connected, closing old connection.
1394531708: New client connected from 192.133.12.45 as Driver1 .

Actually the flow of events is like this ---
1. From client app (an android app) a long polling is initiated towards server side app (which is a J2EE application) to get certain notification events.
2. In the server app a mqttClient is created with the userId passed in from the client. After creating the MqttClient it subscribes to a topic.
3. A third party pushes notification events and the messages are published to a certain topic. The callback receives the messages and does some processing and returns them back to the client.

The problem actually occurs when the same user calls the server app for the 2nd time. If a connection already exists for that user, it is dropped and a new connection is created. Here mqtt clientID is same as the UserID.As a result we see the above log messages. Now I guess it is not causing any functional problem as of now; but I wonder if we put this under heavy load then how is it going to behave? My worrie is what happens to the aborted connection and the thread that created it? Can it anyway cause some performance issues?

Thanks.


On Tuesday, March 18, 2014 3:59 PM, Ian Craggs <icraggs@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
It's difficult to pinpoint without more information.  The first place I would look is in the mosquitto log to see if there is any more information there.

The previous connection will need to be closed before opening a new one.  You say that

"What I suspected is that the client is not closing the previous connection"

How are you expecting the connection to be closed?  At what point do you create a new client instance?

Ian


On 03/17/2014 03:24 PM, ratnopam chakrabarti wrote:
Hi,

I am getting the following EOFException in the server log ---

00:00:12,054 ERROR [stderr] Connection lost (32109) - java.io.EOFException
00:00:12,054 ERROR [stderr] (MQTT Rec: ATTDriver1)      at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138)
00:00:12,054 ERROR [stderr] at java.lang.Thread.run(Thread.java:724)
00:00:12,055 ERROR [stderr] Caused by: java.io.EOFException
00:00:12,055 ERROR [stderr] at java.io.DataInputStream.readByte(DataInputStream.java:267)
00:00:12,055 ERROR [stderr]  at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56)
00:00:12,055 ERROR [stderr] at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100)
00:00:12,055 ERROR [stderr]    ... 1 more

Please help !!

Thanks,
R Chakrabarti


On Friday, March 14, 2014 11:05 AM, ratnopam chakrabarti <ratnopam_ch@xxxxxxxxxxx> wrote:
Hi All,

I am working in an enterprise project and we are using mosquitto broker and mqtt paho client to achieve message communication between our application and other third party applications. From our application we are creating MqttClient to both subscribe and publish operation. While creating the client we are sometimes facing "Client persistence is already in use" exception in the logs. What I suspected is that the client is not closing the previous connection and when we try to create the second client with the same client Id, it is throwing the above error. So I manually closed the connection after processing is done and disconnected. The code snippet - 

MqttClient subClient = new MqttClient(brokerURL, clientId); --- creating the client

For disconnecting ----

client.unsubscribe(configManager.getStringParam(HwaConfigurationConstants.MQTT_SUBSCRIBER_TOPIC) + userId);
client.disconnect(5000);
client.close();

But it still did not work. Then I changed the code a bit to this
MqttClient subClient = new MqttClient(brokerURL, clientId, new MemoryPersistence()); --- creating the client

Now we have not encountered the "Persistence is use " error. But what we are seeing is lot of times "Connection Lost" error is coming in the logs. Any idea here will be highly appreciated as to why this might happen and also if we are creating the client and using persistence in the correct manner.

Thanks,
R Chakrabarti

_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/paho-dev




_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/paho-dev

-- 
Ian Craggs                          
icraggs@xxxxxxxxxx                 IBM United Kingdom
Committer on Paho, Mosquitto


_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/paho-dev



Back to the top