[solved] Cant connect to mqtt broker with openhab 4.1.2

Ive resorted to rebuilding my project in OpenHab 4.1.2 after catastrophic loss of my OpenHab 3 production and backups.

i cant get the mqtt broker to connect on OpenHab 4 … it returns the following error when i use setting that currently work on OpenHab 2 (currently my only working version )

CONNECT failed as CONNACK contained an Error Code: BAD_USER_NAME_OR_PASSWORD.

I suspect the issue is related to the allowable length of the mqtt username field. Perhaps it has been reduced in OpenHab 4? The flespi mqtt broker requires a 64 character token as the username and blank password. However it offers a much more involved token configuration to allow truncated 16 character versions of the token. I will continue to investigate in this direction.

Here is the OpenHab4 code for the broker thing
Note that this broker requires a large token string as the MQTT username and no password.
It fails to connect using a valid token that is working in OpenHab 2 and with newly created token

UID: mqtt:broker:73269d7639
label: flespi MQTT Broker
thingTypeUID: mqtt:broker
lwtQos: 0
publickeypin: true
keepAlive: 30
clientID: OpenHab4
hostnameValidated: false
birthRetain: false
secure: false
certificatepin: true
shutdownRetain: false
protocol: TCP
password: “”
qos: 0
reconnectTime: 10000
port: 1883
mqttVersion: V3
host: mqtt.flespi.io
lwtRetain: false
enableDiscovery: true
username: 6tihMVtY2 - actual 60 character token pasted directly from broker account - GdARifFjH0o
location: Cottage

Does anyone have experience with the flespi broker connection using OpenHab 4 ?

Thanks, John


Ok, I was right in suspecting the mqtt username / password length limitation was the issue.
FLESPI message broker offered the following solution that has led to successful connection:

"use token id as username and at least 16 first bytes of the token key as a password. The token MUST be of ACL type.