There seems to be 2 config files for my binding,

I installed the mqtt binding and it installed properly I think. Although I have 2 config files for it.

The files are;

\OPENHABIANPI\openHAB-share\openhab2-userdata\config\org\openhab\mqtt.config
\OPENHABIANPI\openHAB-share\openhab2-conf\services\mqtt.cfg

I edited the mqtt.cfg as per the binding page. But it seems like it’s using the mqtt.config to connect to mosquitto. The .config file also appears to be a combination of the .cfg file and some other unknown file.

The contents of my .cfg are

mqtt:mosquitto.url=tcp://localhost:1883
mqtt:mosquitto.user=openhabian
mqtt:mosquitto.pwd=mypassword

The contents of my .config are

mosquitto.pwd="mypassword"
mosquitto.url="tcp://localhost:1883"
mosquitto.user="openhabian"
mqqt:mosquitto.clientId="openhab"
mqqt:mosquitto.pwd="secondpassword"
mqqt:mosquitto.url="tcp://localhost:1883"
mqqt:mosquitto.user="openhabian"
service.pid="org.openhab.mqtt"

the second password doesn’t get updated when I update the .cfg file but the first password does.

The error I get from the openhab log is

2017-03-29 19:19:55.881 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
Unable to connect to server (32103) - java.net.ConnectException: Connection refused (Connection refused)
	at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:75)[183:org.openhab.io.transport.mqtt:1.9.0]
	at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:538)[183:org.openhab.io.transport.mqtt:1.9.0]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)[:1.8.0_121]
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)[:1.8.0_121]
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)[:1.8.0_121]
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)[:1.8.0_121]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)[:1.8.0_121]
	at java.net.Socket.connect(Socket.java:589)[:1.8.0_121]
	at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:66)[183:org.openhab.io.transport.mqtt:1.9.0]
	... 2 more

Is there a config file somewhere else its getting the other info from. If I delete the .config file it just gets regenerated.

The .conf that you want to edit is the one in the openhab2-conf/services folder. It then gets cached into the userdata folder during the OH startup.

It’s not the ‘proper’ way to do it but you should be able to just delete the cached copy if it gets out of sync with the services folder version. Restart the OH service and it’ll re-cache the new version.

I think the proper way is to log into the console and do a config:delete org.openhab.weather and it should also remove this file.

Not sure if this will help with the errors thought…

I want to add that touching the cached file is normally not necessary. I’ve never done that, didn’t even know where it’s stored exactly.

The enduser should not edit the userdata folder. openHABian exposes it solely for backup reasons.

I agree except there are some things that can only be configured by editing files in userdata/etc (e.g. logging, karaf console login). Also, there are some problems that can occur that can be fixed by editing or deleting the config files, specifically if you delete a parameter from a services/*.cfg like a broker connection config in mqtt.cfg, it doesn’t get deleted in the config file.

So, maybe instead of “The end user should not edit…” a better statement would be “Only advanced users should edit…”, at least until we can configure logging from the conf file and the issue mentioned above gets fixed.

I’m actually OK with standardizing on doing things through karaf console where possible rather than editing stuff in userdata, but we need to make a conscious decision to do that and update the docs accordingly.

Side note, is there a way to change the logging config in a persistent way through karaf console or must one physically edit the pax config file?

1 Like

Yeah I agree, this fixed my issue with it having the incorrect settings. Seems to cache them, if you change it it edits them but if you change the broker name it creates a new entry. Deleting the file the proper way as described above through the karaf console, or editing values works the best.

I’m still having issues connecting to the moquitto broker. I am using openhabian and I still get connection refused. Are there any permissions I need enabled for this to work. The command I am using is

mosquitto_sub -h localhost -t hello/world -u openhabian -P password

and I get this in response

 Error: Connection refused

Connection refused indicates that the mosquitto server is up and running but will not accept connections. This can be caused by a firewall, mosquitto configured to only listen for connections from a certain subnet or localhost, or mosquitto may not be running at all. I don’t use openhabian so can’t say if any of these would be an expected problem.

Hey Derek,
I guess this is my fault :cold_sweat: I’ve just added the needed bugfix to openHABian. In your already broken setup please fix it manually by removing the four suspicious lines from /etc/mosquitto/mosquitto.conf, see the following for more details: openHABian hassle-free openHAB Setup

1 Like

Thanks