MQTT - connections lost -

Hi Team

I would like a clue on moving forward. Thinks are not behaving as expected…

Found this entry: New to MQTT and OH, trouble getting the binding down
Which is a good match, and have looked at that and here the suggestion is go get something into the events.log first – and I’m having problems with that… nothing happens.

I have created an test.items, added this line:

String freezer_inside [“Freezer %s”] {mqtt=“<[oh2:borand/shed/freezer/temp_inside_freezer]”}

And I could image it is wrong, but is hoping that something will show somewhere… - nothing. Have restarted and all that stuff.

MQTT is working:

pi@raspbox3:/etc/openhab2/items $ mosquitto_sub -h localhost -d -t borand/shed/freezer/temp_inside_freezer
Client mosqsub/24929-raspbox3 sending CONNECT
Client mosqsub/24929-raspbox3 received CONNACK
Client mosqsub/24929-raspbox3 sending SUBSCRIBE (Mid: 1, Topic: borand/shed/freezer/temp_inside_freezer, QoS: 0)
Client mosqsub/24929-raspbox3 received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/24929-raspbox3 received PUBLISH (d0, q0, r0, m0, ‘borand/shed/freezer/temp_inside_freezer’, … (7 bytes))
-14.062

mqtt.cfg contains these lines:

URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

oh2.url=tcp://localhost:1883

Optional. Client id (max 23 chars) to use when connecting to the broker.

If not provided a default one is generated.

oh2.clientId=OpenHAB2_MQTT

In openhab.log I get these entries:

2016-12-23 09:59:39.323 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘oh2mqtt’
2016-12-23 09:59:39.635 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘oh2’
2016-12-23 09:59:39.661 [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)[199:org.openhab.io.transport.mqtt:1.9.0.201612130210]
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:56)[199:org.openhab.io.transport.mqtt:1.9.0.201612130210]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100)[199:org.openhab.io.transport.mqtt:1.9.0.201612130210]
… 1 more
2016-12-23 09:59:39.677 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ‘oh2mqtt’ was lost: Connection lost : ReasonCode 32109 : Cause : null
2016-12-23 09:59:39.678 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker ‘oh2mqtt’
2016-12-23 09:59:49.679 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘oh2mqtt’
2016-12-23 09:59:49.693 [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)[199:org.openhab.io.transport.mqtt:1.9.0.201612130210]
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:56)[199:org.openhab.io.transport.mqtt:1.9.0.201612130210]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:100)[199:org.openhab.io.transport.mqtt:1.9.0.201612130210]
… 1 more
2016-12-23 09:59:49.695 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to ‘oh2’ was lost: Connection lost : ReasonCode 32109 : Cause : null
2016-12-23 09:59:49.696 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker ‘oh2’

Here we get both a ‘oh2’ and a ‘oh2mqtt’ – I had the oh2 first, then changed it to oh2mqtt, but then I noticed the two entries, and changed it back (in mqtt.cfg) – and restart… but something is stored somewhere…

I have found this entry:

which also talks about two mqtt entries, and that it can be solved by “Karaf Console (ssh openhab@localhost -p 8101 with password: habopen) “

Tried to run this ssh command, but comes out and askes for password – guess the openhab users, but the password is openhab and is not ‘taken’ when I type it…

So, what is the next step…

Did this again… and this time i noticed that the user id and password are not the same :wink: Karaf Console (ssh openhab@localhost -p 8101 with password: habopen)

This works … had two entries in db… removed it all, restarted box, and the errors are now gone from the got the registry openhab.log

Still nothing in events.log… so have to look more af the items def.

Hi … all is now working… Guess it was not enough to have it defined in the items, it also needed to be referenced/used from a site, before the ‘call’ to mqtt where made… now it is showing value at site…

It almost looks like there is some structure into this setup :wink:

/Jørn

All item are uninitialized (have no actual state or value) at first start (f.e. after rebooting).
You can avoid that if you use a persistence service and restoreOnStartup.