MQTT connectin was lost!

This keeps popping repeatedly !!
I have set up my broker (mosquito) but I just cant seem to post anything on it

I’m running openHab and Mosquito locally on a Raspberry Pi 2

11:29:13.188 [ERROR] [o.i.t.m.i.MqttBrokerConnection:540 ] - MQTT connection to ‘broker’ was lost: Connection lost : ReasonCode 32109 : Cause : null
11:29:13.190 [INFO ] [o.i.t.m.i.MqttBrokerConnection:547 ] - Starting connection helper to periodically try restore connection to broker 'broker’
11:29:16.118 [DEBUG] [.o.b.s.internal.SonanceBinding:136 ] - There is no existing Sonance binding configuration => refresh cycle aborted!
11:29:23.191 [INFO ] [o.i.t.m.i.MqttBrokerConnection:114 ] - Starting MQTT broker connection 'broker’
11:29:23.319 [ERROR] [o.i.t.m.i.MqttBrokerConnection:536 ] - MQTT connection to broker was lost
org.eclipse.paho.client.mqttv3.MqttException: Connection lost
at [mqtt-client-0.4.0.jar:na]
at [na:1.8.0_65]
Caused by: null
at ~[na:1.8.0_65]
at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage( ~[na:na]
at [mqtt-client-0.4.0.jar:na]
… 1 common frames omitted

Look in your syslogs (assuming that is where you configured mosquitto to log to) and see what mosquitto says is going on. The repeated connection lost implies that mosquitto is crashing then restarting.

That’s what I thought too
But my broker is working fine
I have subscribed devices to it and posted messages successfully !

Searching on the Internet I came up with many suggestions saying that “connection lost” indicate a security issue !!

Did you find a resolution to this?

Just hit the same issue (I believe)
My mosquitto log claims that OH is trying to connect AGAIN so it (mosquitto) drops the existing connection.
Any idea what to change ?

Make sure you use a different client id for each client that connects to the broker. When you reuse the client ID the broker things that the same client is trying to reconnect and closes down any connections it already has open with that client id. Note that the client id is not the same as username which is used for authentication. The default client id is “openhab” I believe for the mqtt binding.

Yes, it was caused by double ID because I had two OH instances running. One of these itchy-quirky-somethings you easily forget about in the heat of a migration. Thanks anyway.

1 Like