MQTT Not Connecting?

I’ve been struggling to get my Milight remote working per the solutions topic here, and though better to start a new topic vs clutter up the solutions one.

I have followed that guide 100%, yet still having issues and think it could be something in my setup. I am running OH2, latest snapshot on Ubuntu Server 16.04.

Mosquitto is running on my machine and I can Sub to all topics like such and see OwnTracks and the Milight remote publishing

mosquitto_sub -v -u openhab -P MYPASS -p 1883 -t '#'

But in my OH2 logs, I see no information that OH2 is even connecting to the Mosquitto broker? I have the 1.11 mqtt binding installed and the mqtt.cfg file looks as follows:

mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openhabserver
mosquitto.user=openhab
mosquitto.pwd=MYPASS
mosquitto.retain=false
mosquitto.async=true

The openhab user and pass is also included in my /etc/mosquitto/passwd file, and for now I also have ## commented out using the password file in my mosquitto.conf file.

So when OH2 starts, shouldn’t I see something in the logs that it is connected to the mosquitto broker?

In trying to troubleshoot more, I see this the mosquitto logs. Is OH2 not connecting to the broker?

1509988890: New connection from ::1 on port 1883.
1509988890: New client connected from ::1 as mosqsub/18993-OpenHab2 (c1, k60, u'openhab').
1509989156: Socket error on client mosqsub/18993-OpenHab2, disconnecting.

Yes, something like:

2017-11-06 10:37:33.627 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-11-06 10:37:33.636 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'

Maybe your are effected by:

or

1 Like

Finally, thank you!!!

Deleting that old, stale mqtt.cfg file from the var/lib… fixed the issue. Now on a restart I see OH2 connecting to the broker and now see things updating in the log.

I think just need to get the rules setup now and should hopefully be ok with things.

2 Likes

Kudos go to @Dim :grinning:

1 Like

In theory, this story with the stale configs will disappear soon…

Source: https://github.com/openhab/openhab-distro/issues/396#issuecomment-332236729

I haven’t tested this yet on my Snapshot but it should work.

1 Like

Alright, time to update then…