|Re: [paho-dev] Experiencing constant reconnects with paho client v1.1.1 and broker Active MQ 5.14.3|
Software Engineer - IoT Foundation - MQTT Open Source Projects
Ops Team - Wimbledon Project
----- Original message -----
From: Martin Eden <martineden131@xxxxxxxxx>
Sent by: paho-dev-bounces@xxxxxxxxxxx
Subject: [paho-dev] Experiencing constant reconnects with paho client v1.1.1 and broker Active MQ 5.14.3
Date: Mon, May 15, 2017 11:08 AM
I am experiencing constant reconnects from my Paho MQTT subscriber and publisher clients running inside a JVM on my Mac talking to a Active MQ instance running in Virtual BOX also on my Mac.
It is an integration test where I am trying to test a simple app that runs two paho mqtt clients: a subscriber and a publisher. The subscriber subscribes to a topic, reads the messages via callback, processes them and then passes them to the publisher that will publish them to another topic. So this main app has 2 paho clients, separately instantiated like so (Scala code):
The point of the integration test is to verify that by enabling persistent session on the subscriber client (options.setCleanSession(false
) and new MqttDefaultFilePersistence() above), we can consume the messages published to the topic during app downtime.
The test is simple:
- start main app.
- use a 3rd paho client (publisher) that publishes 1 message to the input topic.
- use a 4th paho client (subscriber) to check the expected message was published back to the output topic by the main app.
- kill app
- use the 3rd publisher paho client to publish 1 more message in the input topic.
- start app.
- use the 4th paho client (subscriber) to check the expected message was published back to the output topic by the main app.
The 3rd and 4th clients are instantiated by the test like so:
val mqttClient = new MqttClient(mqttBrokerUrl, MqttClient.generateClientId, new MemoryPersistence)
What happens is that all the messages get through as expected BUT the subscriber paho client, after the second start of the main app, continuously spits out:
The first time the app is started this does not happen! Only the second time!
Doing some digging around it seems people suggest this happens when you have two clients with the same id. This is not the case as all the ids are different. This is shown also in the Active MQ broker UI:
Name Remote Address Active Slow
paho1493328011500000000 tcp://192.168.99.1:58421 true false
sub tcp://192.168.99.1:59426 true false
pub tcp://192.168.99.1:59427 true false
paho1493328011993000000 tcp://192.168.99.1:58424 true false
"sub" and "pub" being the ids for the paho clients in main app.
"paho1493328011500000000" and "paho1493328011993000000" being the randomly generated ids for the paho clients 3 and 4 in the test.
Furthermore, the Active MQ server logs continuously print lines like these:
So it seems there is constant link stealing between the paho clients in the main app with ids "sub" and "pub".
Can anyone shed light on this behavior? Why is it happening? It does not seem normal. Why does it happen if the ids are different? How can I prevent it?
Sorry for the long message. Any help is much appreciated._______________________________________________
paho-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit