I am using OH2b4 with the MQTT binding. I have discovered two issues with MQTT:
- OH2 wants to create two connections to MQTT broker although I have only defined one. In services/mqtt.cfg I defined a broker called “home”. Everything worked fine so far. Later on I decided to rename it in the cfg-file to “homebroker”. Since then OH2 always wants to connect to two brokers “home” and “homebroker”. I don’t know where it still takes the old name “home” from - is it saved in some kind of internal database and how do I get it removed? I have restarted OH2 several times now and it still uses the old and the new name of the broker in parallel.
- Maybe this is linked to the first issue: OH2 gets disconnected form my MQTT broker (mosquitto) frequently and mosquitto.log says
1474751407: New client connected from 192.168.x.y as OpenHAB2 (c1, k60). 1474751417: New connection from 192.168.x.y on port 1883. 1474751417: Client OpenHAB2 already connected, closing old connection. 1474751417: Client OpenHAB2 disconnected.
At the same time openhab2.log says:
2016-09-24 23:11:37.905 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'home' 2016-09-24 23:11:47.934 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'home' 2016-09-24 23:11:47.951 [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:138)[193:org.openhab.io.transport.mqtt:1.9.0.b4] at java.lang.Thread.run(Thread.java:745)[:1.8.0_101] Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_101] at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56)[193:org.openhab.io.transport.mqtt:1.9.0.b4] at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100)[193:org.openhab.io.transport.mqtt:1.9.0.b4] ... 1 more 2016-09-24 23:11:47.954 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'homebroker' was lost: Connection lost : ReasonCode 32109 : Cause : null 2016-09-24 23:11:47.955 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'homebroker' 2016-09-24 23:11:57.974 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'homebroker' 2016-09-24 23:11:57.991 [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:138)[193:org.openhab.io.transport.mqtt:1.9.0.b4] at java.lang.Thread.run(Thread.java:745)[:1.8.0_101] Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_101] at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:56)[193:org.openhab.io.transport.mqtt:1.9.0.b4] at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100)[193:org.openhab.io.transport.mqtt:1.9.0.b4] ... 1 more 2016-09-24 23:11:57.993 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'home' was lost: Connection lost : ReasonCode 32109 : Cause : null 2016-09-24 23:11:57.993 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'home'
I can connect fine to the broker using node-red and weewx (both on port 1883) as well as the HiveMQ websocket client in the browser on another port. I assume it’s a problem with OH2 / MQTT-binding. Any ideas how to solve this? I would like to use MQTT for loose coupling of some components such as OH2, weewx and node-red.