Hi, Related to what Ragoubi is experiencing, I posted a message a few days ago with this title: *Experiencing constant reconnects with paho Java client v1.1.1 and broker Active MQ 5.14.3.*
I am basically seeing constant reconnects for both MqttClient instances (one subscriber and one publisher) used by my app. Like in Ragounbi's case, the reconnects happen roughly every 1 sec as seen below from both server and client logs. Unlike him I have set auto reconnect for both clients. Unlike him I also have a long running app, constantly reading data from the MQTT broker and publishing back on another topic on the same broker. I also tried the Mosquitto broker with the same behavior. Can someone help figure this out? Thanks, M P.S. Detailed ActiveMQ and Mosquitto broker logs as well as Paho Java 1.1.1 client logs below. Active MQ broker logs: 2017-04-27 21:44:48,487 | WARN | Stealing link for clientId sub From Connection Transport Connection to: tcp://192.168.99.1:61766 | org.apache.activemq.broker.region.RegionBroker | ActiveMQ Transport: tcp:///192.168.99.1:61768@1883 2017-04-27 21:44:48,832 | WARN | Stealing link for clientId pub From Connection Transport Connection to: tcp://192.168.99.1:61767 | org.apache.activemq.broker.region.RegionBroker | ActiveMQ Transport: tcp:///192.168.99.1:61769@1883 2017-04-27 21:44:49,497 | WARN | Stealing link for clientId sub From Connection Transport Connection to: tcp://192.168.99.1:61768 | org.apache.activemq.broker.region.RegionBroker ... Also tried with Mosquitto 1.4.10. Broker logs: 1494930100: mosquitto version 1.4.10 (build date 2016-10-26 14:35:35+0000) starting 1494930100: Config loaded from /mosquitto/config/mosquitto.conf. 1494930100: Opening ipv4 listen socket on port 1883. 1494930100: Opening ipv6 listen socket on port 1883. 1494930171: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930171: New client connected from xxx.xxx.xxx.xxx as paho1494930171596000000 (c0, k60). 1494930171: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930171: New client connected from xxx.xxx.xxx.xxx as paho1494930171987000000 (c1, k60). 1494930173: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930173: New client connected from xxx.xxx.xxx.xxx as sub (c0, k60). 1494930175: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930175: New client connected from xxx.xxx.xxx.xxx as pub (c0, k60). 1494930182: Socket error on client sub, disconnecting. 1494930183: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930183: Client sub disconnected. 1494930183: New client connected from xxx.xxx.xxx.xxx as sub (c0, k60). 1494930184: Socket error on client sub, disconnecting. 1494930185: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930185: Client sub disconnected. 1494930185: New client connected from xxx.xxx.xxx.xxx as sub (c0, k60). 1494930185: Socket error on client sub, disconnecting. 1494930186: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930186: Client sub disconnected. 1494930186: New client connected from xxx.xxx.xxx.xxx as sub (c0, k60). 1494930187: Socket error on client sub, disconnecting. 1494930188: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930188: Client sub disconnected. 1494930188: New client connected from xxx.xxx.xxx.xxx as sub (c0, k60). 1494930189: Socket error on client sub, disconnecting. 1494930190: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930190: Client sub disconnected. 1494930190: New client connected from xxx.xxx.xxx.xxx as sub (c0, k60). 1494930190: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930190: Client sub already connected, closing old connection. 1494930190: Client sub disconnected. 1494930190: New client connected from xxx.xxx.xxx.xxx as sub (c0, k60). 1494930190: New connection from xxx.xxx.xxx.xxx on port 1883. 1494930190: Client pub already connected, closing old connection. 1494930190: Client pub disconnected. 1494930190: New client connected from xxx.xxx.xxx.xxx as pub (c0, k60). 1494930191: New connection from xxx.xxx.xxx.xxx on port 1883. On the client I see these errors every roughly 1 sec as well (if using both brokers). Note using 2 paho MqttClient instances subscribed to the same broker, one subscriber (with id sub) and one publisher with id (pub). Both clients are set to auto reconnect. App logs when running with ActiveMQ: 17/05/17 18:55:03,964 ERROR MQTTSource: Connection lost for MqttClient with id [sub]; going to auto-reconnect Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:164) at java.lang.Thread.run(Thread.java:745) 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:116) ... 1 more 17/05/17 18:55:03,976 ERROR MQTTSink: Connection lost for MqttClient with id [pub]; going to auto-reconnect Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:164) at java.lang.Thread.run(Thread.java:745) 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:116) ... 1 more 17/05/17 18:55:04,988 ERROR MQTTSource: Connection lost for MqttClient with id [sub]; going to auto-reconnect Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:164) at java.lang.Thread.run(Thread.java:745) 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:116) ... 1 more 17/05/17 18:55:04,995 ERROR MQTTSink: Connection lost for MqttClient with id [pub]; going to auto-reconnect Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:164) at java.lang.Thread.run(Thread.java:745) 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:116) ... 1 more App logs when running with Mosquitto (just messages for pub showed below): 17/05/17 18:43:57,810 ERROR MQTTSink: Connection lost for MqttClient with id [pub]; going to auto-reconnect Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:164) at java.lang.Thread.run(Thread.java:745) 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:116) ... 1 more 17/05/17 18:43:58,816 ERROR MQTTSink: Connection lost for MqttClient with id [pub]; going to auto-reconnect Connection lost (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:164) at java.lang.Thread.run(Thread.java:745) 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:116) ... 1 more All the logs above are from different runs so don't try to match the time stamps in between server and client logs, they are different. On Wed, May 17, 2017 at 4:05 PM, aragoubi <aymen....@gmail.com> wrote: > This at the end of code, I am getting the problem just when I connect > (IMqttToken token = sampleClient.connect(connOpts);). > When I debug, I stop just after the connection line, and first the > connectComplete(boolean reconnect, String serverURI) method of the callback > is invoked and just after a second the connectionLost(Throwable cause) is > invoked. > > > > > -- > View this message in context: http://activemq.2283324.n4. > nabble.com/Connection-to-activemq-broker-is-lost-within-one-second- > tp4726204p4726256.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. >