[SOLVED] Remove mqtt connections/brokers

recently i’ve been trying to get a mqtt service running with failures then finally success in the end. however, i have noticed something in the logs when starting openhab or stopping/starting the broker. i have multiple connections established when i only have one set up in /etc/openhab2/services/mqtt.cfg. the logs say:

2018-01-01 20:59:08.562 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-01-01 20:59:08.566 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'test'
2018-01-01 20:59:09.081 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'test2'
2018-01-01 20:59:09.145 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'

but my mqtt.cfg file only has ‘broker’ set up

broker.url=tcp://localhost:1883

how do i disconnect or remove the other two ‘test’ and ‘test2’ connections? i created those initially when trying to figure out how everything works.

You should clear the caches.

i deleted the files in /var/lib/openhab2/cache/ and /var/lib/openhab2/tmp/ but nothing has changed. i’m still seeing the two connections.

i also started mosquitto in verbose mode and have 3 separate connections from the same IP address. only one of them has a subscription (the one i’m actually using).

this post helped

HowTo: Manage OpenHab 2 configurations

is it really necessary to ssh into the Apache Karaf Console? openhab is installed onto the system im working on… the config files should be accessible in the first place, right?

How you acccess the Karaf console probably depends on how you’re starting OH, but yes, config files should be accessible outside of the Karaf console.

do you know the location of the config files. i looked in /usr/share/openhab2/runtime/ but couldnt find anything relevant.

Depends how you installed OpenHab. Try /etc/openhab2

i found the files.

/var/lib/openhab2/config contains the the config files
/etc/openhab2 contains data that is copied into /var/lib/openhab2

the actual file i was looking for was /var/lib/openhab2/config/org/openhab/mqtt.config

you can also edit these files using linux command “openhab-cli console” or connecting using ssh with openhab@[IP address] on port 8101

a lot of this information can be found from https://docs.openhab.org/administration/console.html

1 Like

Excellent work, thank you. I removed old brokers from /var/lib/openhab2/config/org/openhab/mqtt.config using sudo nano. The problem with old brokers now seems te be over.