Hi
I am using JavaScript / mqtt.js to connect to a Mosquitto broker.
I had everything working, and then I upgraded to the Mosquitto version 2.0.15, and now I cannot connect to the broker.
Could you read the following, and see if you have any suggestions, plase.
Thanks
Garrett
OLD SET UP
I had v1.6.9 Mosquitto installed and running on Ubuntu (in Google Cloud).
I was able to communicate with the broker using:
(a) desktop web client
(b) MQTT Explorer
(c) JavaScript using mqtt.js
NEW SETUP
I upgraded to latest Mosquitto version 2.0.15.
I had to create a username and password, so I used the instructions here:
https://mosquitto.org/documentation/authentication-methods/
I edited the mosquito.conf file, so it knows about the password file.
I restarted the VM and then started Mosquitto.
WHAT STILL WORKS
Now, I am able to communicate with the broker (with username/password) using:
(a) desktop web client
(b) MQTT Explorer
But not
(c) JavaScript using mqtt.js
mqtt.js connect options
In JavaScript, my connect options used to be of the form (for v1.6.9):
const connection_options = {
port: 1883,
host: host,
clientId: client_id,
clean: true,
keepalive: false,
reconnectPeriod: 5000
};
where host is the IP address of the machine
And are now of the form (for v2.0.15):
const connection_options = {
port: 1883,
host: host,
> username: ‘user’,
> password: ‘password’,
clientId: client_id,
clean: true,
keepalive: false,
reconnectPeriod: 5000
};
I have double checked the username / password values etc.
So, the only thing I changed was adding the username and password, but I can no longer connect with the broker.
The desktop web client, MQTT Explorer and the JavaScript/mqtt.js are all using the same IP address, same port, same username and password.
Any help / suggestions greatly appreciated