B4J Tutorial MQTT: Mosquito over websockets

aminoacid

Active Member
Licensed User
Longtime User
Hi Fam

Back to these challenges...


Great article. Very complete and concise. Setting up your own Mosquitto Broker is fairly easy. I have set it up on Windows and Ubuntu and both have been running flawlessly now for 2 years. To cover all possible MQTT connections, I have the Broker configured for four "listeners" on separate ports. This is my config file in case anyone is interested:


B4X:
allow_anonymous false
password_file c:\mosquitto\passwords.txt
# Port to use for the default listener. TCP
port 1883
# Additonal Listner Port to use for SSL. What follows is for Additional port
listener 8883
# cafile C:\mosquitto\certs\ca.crt
certfile C:\mosquitto\certs\weatheractive.cer
keyfile C:\mosquitto\certs\weatheractive.key
# tls_version tlsv1 -disabled- allow all tls versions
# regular websockets - no SSL
listener 9001
protocol websockets
# Websockets with SSL
listener 9003
protocol websockets
certfile C:\mosquitto\certs\weatheractive.cer
keyfile C:\mosquitto\certs\weatheractive.key
# cafile C:\mosquitto\certs\ca.crt

The SSL certificates I use are Ionos certificates although I have also used the LetsEncrypt and ZeroSSL free certs without any issues. The "cafile" is generally not required.
 
Top