Openhab MQTT binding getting 'Not Authorised' result

Hi,
I’m trying to connect Openhab running on a separate Pi to the MQTT broker on the Emonpi but I continually get Error message 5 - Not Authorised;

017-05-31 21:21:07.073 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-05-31 21:21:07.075 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ‘emonpi’
2017-05-31 21:21:07.206 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
Not authorized to connect (5)
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:24)[183:org.openhab.io.transport.mqtt:1.9.0]
at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:773)[183:org.openhab.io.transport.mqtt:1.9.0]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:110)[183:org.openhab.io.transport.mqtt:1.9.0]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

I’ve run a few other connection tests from Mosquitto and my PC but they all get the same? How can I connect to the MQTT Broker on the Emonpi?

Thanks

This is starting to drive me around the bend…
I’ve tried using the default credentials, not authorised
I’ve tried creating a new user and password, not authorised
I’ve tried allowing anonymous connections… it claims to connect but when i subscribe to any topic, theres nothing…

Next level of odd; with anonymous connections allowed, I can pub and sub to a topic of my creation between two SSH terminals. But the same message isn’t received by a client listing on my PC to the same broker.

The stupid thing is that I have connected perfectly well before now. The only thing I can think that has changed is a power cut a few days back but I don’t recall if the connection issue started before or after that,

My log in the emoncms just shows this over and over again;

2017-06-01 10:17:02,833 WARNING MQTT Connection refused - not authorised
2017-06-01 10:17:02,834 DEBUG MQTT CONACK => Return code: 5
2017-06-01 10:17:02,835 INFO MQTT Unexpected disconnection
2017-06-01 10:17:02,935 INFO MQTT Connecting to MQTT Server
2017-06-01 10:17:02,938 WARNING MQTT Connection refused - not authorised
2017-06-01 10:17:02,939 DEBUG MQTT CONACK => Return code: 5
2017-06-01 10:17:02,940 INFO MQTT Unexpected disconnection
2017-06-01 10:17:03,041 INFO MQTT Connecting to MQTT Server
2017-06-01 10:17:03,043 WARNING MQTT Connection refused - not authorised
2017-06-01 10:17:03,044 DEBUG MQTT CONACK => Return code: 5
2017-06-01 10:17:03,045 INFO MQTT Unexpected disconnection
2017-06-01 10:17:03,146 INFO MQTT Connecting to MQTT Server
2017-06-01 10:17:03,149 WARNING MQTT Connection refused - not authorised

I’ve got to be missing something here? Anyone got any ideas?

Thanks

OK, I realise I’m basically talking to myself here but I seem to have resolved it and thought I’d pass it on in case anyone else gets the same issue.

All it took was to reset the MQTT password for the emonpi user to the default ‘emonpimqtt2016’ (even though I never changed it)
sudo mosquitto_passwd -c /etc/mosquitto/passwd emonpi

this allowed subscribers on other machines to connect to the broker anonymously?!

Currently allow anonymous connections is set to TRUE in MQTT config on emonpi and I’m reluctant to turn it back to the default False in case I break it. So my Openhab MQTT config isn’t using any credentials and can connect just fine.

1 Like

The default emonPi MQTT authentication is:

username: emonpi
pass: emonpimqtt2016

port 1883

I’m looking to do the same thing, run emonpi on a separate pi and keep my Openhab setup separate. Is that something you’d recommend?