[SOLVED] MQTT works fine but error message in log

Hi all,

I just started with openHAB and so far it’s going fine.
Running openHABianPI 2.4 with the embedded MQTT server which is working (Sonoffs and Shellies implemented).
However, it’s constantly writing the following error to the log:

2019-03-27 22:30:20.186 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to 'openhabianpi'. Next attempt in 10000ms
2019-03-27 22:30:20.200 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to 'openhabianpi' with clientid paho240689520484113 and file store '/var/lib/openhab2/mqtt/openhabianpi'
2019-03-27 22:30:20.218 [ERROR] [.moquette.spi.impl.ProtocolProcessor] - Authenticator has rejected the MQTT credentials CId=paho240689520484113, username=openhabian
2019-03-27 22:30:20.269 [ERROR] [.moquette.spi.impl.ProtocolProcessor] - Authenticator has rejected the MQTT credentials CId=paho240689520484113, username=openhabian

I am not sure what is causing this. In the embedded broker, I am not even using this username.
The error comes from the following bit in MQTT’s ProtocolProcessor.java file:

private  boolean login(Channel channel, MqttConnectMessage msg, final String clientId) {
        // handle user authentication
        if (msg.variableHeader().hasUserName()) {
            byte[] pwd = null;
            if (msg.variableHeader().hasPassword()) {
                pwd = msg.payload().password().getBytes();
            } else if (!this.allowAnonymous) {
                LOG.error("Client didn't supply any password and MQTT anonymous mode is disabled CId={}", clientId);
                failedCredentials(channel);
                return false;
            }
            if (!m_authenticator.checkValid(clientId, msg.payload().userName(), pwd)) {
                LOG.error("Authenticator has rejected the MQTT credentials CId={}, username={}, password={}",
                        clientId, msg.payload().userName(), pwd);
                failedCredentials(channel);
                return false;
            }

Best regards

The broker is a bit noisy sometimes. That has changed with the updated version.

Looks like you have more than one broker connection created. Remove all mqtt.cfg and mqtt.config files in your oh user directory while oh is not running, to only use the .thing file and paper UI ones.

Thank you for your reply.

There’s no mqtt.cfg or .config file in any directory. I set up everything via paper UI.

However, by now it had resorted to a reconnect attempt every 10s which stopped after a restart.

2019-03-28 08:32:10.519 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to 'openhabianpi'. Next attempt in 10000ms

So apparently some residual from setting up (and deleting) the embedded MQTT server a few times dring testing.