OH2 MQTT error: connection to broker starts and stops because of multiple broker connections

OH2 (build 4) wants to create two connections to MQTT broker although I have only defined one. In services/mqtt.cfg I defined a broker called “localbroker” and later on I decided to rename it in the cfg-file to “openhab”. Since then OH2 always wants to connect to two brokers “localbroker” and “openhab”. When connection “localbroker” tries to connect to the broker, the “openhab” connection stops and so on…
I have tried several times to restart the broker and OH2, and reboot. And I´ve tried to stop the MQTT bundles in the Karaf console, but nothing works.
I don’t know why it still takes the old name “localbroker” from - is it saved in some kind of internal database and how do I get it removed?

Ive read this tread but the suggestions doesn’t help me, although having the exact same problem

Im desperate to get this to work, and Im on the edge to do a complete reinstall of OH2 on the RasPi.

2016-10-23 08:53:56.983 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ‘openhab’ was lost: Connection lost : ReasonCode 32109 : Cause : null
2016-10-23 08:53:56.987 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker ‘openhab’
2016-10-23 08:54:03.997 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘localbroker’
2016-10-23 08:54:06.992 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘openhab’
2016-10-23 08:54:08.322 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146)[203:org.eclipse.paho.client.mqttv3:1.0.2]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_65]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65)[203:org.eclipse.paho.client.mqttv3:1.0.2]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)[203:org.eclipse.paho.client.mqttv3:1.0.2]
… 1 more
2016-10-23 08:54:08.326 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ‘localbroker’ was lost: Connection lost : ReasonCode 32109 : Cause : null
2016-10-23 08:54:08.328 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker ‘localbroker’
2016-10-23 08:54:18.335 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘localbroker’
2016-10-23 08:54:18.360 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146)[203:org.eclipse.paho.client.mqttv3:1.0.2]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_65]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65)[203:org.eclipse.paho.client.mqttv3:1.0.2]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)[203:org.eclipse.paho.client.mqttv3:1.0.2]
… 1 more
2016-10-23 08:54:18.365 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ‘openhab’ was lost: Connection lost : ReasonCode 32109 : Cause : null
2016-10-23 08:54:18.375 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker ‘openhab’
2016-10-23 08:54:21.319 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘localbroker’
2016-10-23 08:54:28.377 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘openhab’
2016-10-23 08:54:28.402 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
Connection lost (32109) - java.io.EOFException
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146)[203:org.eclipse.paho.client.mqttv3:1.0.2]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_65]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65)[203:org.eclipse.paho.client.mqttv3:1.0.2]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)[203:org.eclipse.paho.client.mqttv3:1.0.2]
… 1 more
2016-10-23 08:54:28.409 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ‘localbroker’ was lost: Connection lost : ReasonCode 32109 : Cause : null
2016-10-23 08:54:28.413 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker ‘localbroker’

Hi, I can report the same issues.

I deleted the entire cache file, but no resolution.

Have you tried deleting the config stored in the Karaf - via the OpenHab console? This worked for me.
See this post - item 8 -

Try to check with the Karaf Console (ssh openhab@localhost -p 8101 with password: habopen) what has been already stored in the OH2 “internal database” by using:

config:edit org.openhab.mqtt
config:property-list

Also, you can use: config:list to show you all bindings configs stored.

You can start clean by configuring your mqtt.cfg and mqtt-eventbus.cfg and clearing out whatever is stored already by:
config:delete org.openhab.mqtt and then restarting OH2 to reload the .cfg file

1 Like

Hi i had this same issue & i solved it my removing double broker entry from /var/lib/openhab2/config/org/openhab/mqtt.config . by mistake i didnt notice the broker i added first time