Cannot get MQTT to work under OH2

I have OH2 (build 642) running under Windows. Work like a charm.
Now i decided to buy some Sonoff devices, so i flashed those, configured them to use MQTT.
Then i installed mosquitto on the same server as OpenHab.
Also works. When i test with: mosquitto_sub.exe -t /home/stue/switch1/POWER i receive messages from the Sonoff device. So my MQTT server works.

But when setting up OpenHab2 as a client, the frustration starts.

The error i see is:

[ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
Connection lost (32109) -
Caused by:
        at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInpu[]
        ... 1 more

I keep getting information in the log about broker connection started with previous used brokers (i renamed it a few times in MQTT.CFG):
[INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘mqtt’
[INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘oh2’
[INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mqtt1
and so on…

I see alot of:
[ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost

In MMQTT.CFG i have:

mqtt.items i have:
Switch MQTTtestitem “MQTTtestitem”
{ mqtt=">[oh2:/home/stue/switch1/RESULT/POWER:command:*:default],
<[oh2:/home/stue/switch1/RESULT/POWER:state:default]" }

In sitemap i have:
Switch item=MQTTtestitem

Any help would be highly appreciated.

I guess you are affected by a little bug which can be resolved:

I was shooting everywhere this morning, and it finally worked!

What i did to resolved it was:

  • Changing the MQTT server to another port (and offcourse the clients)
  • Deleting the file: \userdata\config\org\openhab\mqtt.config

Hope it can help other people in the same situation.

1 Like