[SOLVED] MQTT Not working

I can’t for the life of me get the MQTT binding to work on a server, yet I have a second server with an identical /etc/openhab and it works there. I get this in the logs when starting openhab:

[ERROR] [.io.transport.mqtt.MqttService] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttPersistenceException: MqttException
at org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence.open(MqttDefaultFilePersistence.java:76) ~[na:na]
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.(MqttAsyncClient.java:273) ~[na:na]
at org.eclipse.paho.client.mqttv3.MqttClient.(MqttClient.java:222) ~[na:na]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.openConnection(MqttBrokerConnection.java:297) ~[na:na]
at org.openhab.io.transport.mqtt.internal.MqttBrokerConnection.start(MqttBrokerConnection.java:115) ~[na:na]
at org.openhab.io.transport.mqtt.MqttService.updated(MqttService.java:112) ~[na:na]
at org.eclipse.equinox.internal.cm.ManagedServiceTracker$1.run(ManagedServiceTracker.java:183) [org.eclipse.equinox.cm_1.0.400.v20120522-1841.jar:na]
at org.eclipse.equinox.internal.cm.SerializedTaskQueue$1.run(SerializedTaskQueue.java:36) [org.eclipse.equinox.cm_1.0.400.v20120522-1841.jar:na]

This is my openhab.cfg minus the comments:

logging:pattern=%date{ISO8601} - %-25logger: %msg%n

and this is my dpkg -l | grep openhab output:

ii openhab-addon-action-xmpp 1.7.1 all openHAB XMPP Action
ii openhab-addon-binding-asterisk 1.7.1 all openHAB Asterisk Binding
ii openhab-addon-binding-mqtt 1.7.1 all openHAB MQTT Binding
ii openhab-addon-persistence-mqtt 1.7.1 all openHAB MQTT Persistence
ii openhab-addon-persistence-mysql 1.7.1 all openHAB mySQL Persistence
ii openhab-runtime 1.7.1 all openHAB Distribution

I know mosquitto is working at that address (mosquitto_pub and mosquitto_sub both work at that address), but for some reason I can’t get openhab to connect to it. I’ve tried apt-get remove and apt-get install on openhab-* but there is no difference.

I’m running ubuntu 14.04 LTS.

Looks to me like a file permissions issue.

Any idea where the issue is? The permissions seem to be the same for
/{etc,usr}/openhab between both systems.

The file permission error for MqttDefaultFilePersistence will be in the java.io.tmpdir which in linux defaults to /tmp (unless it’s been changed in the start.sh command via -Djava.io.tmpdir=yourDirectory).
Should be a directory there named after your broker ie. /tmp/yourBrokerName. Check the file permissions there.

OK, I found the /tmp/broker was root:root, I chown’d it as openhab:openhab and now it works, thanks!

I had that happen when I ran openhab as root one time.