Caution! Article for developers

Information on this page is intended particularly for users with advanced technical knowledge.

How to set up an MQTT broker

Jul 5, 2022 · 2 minutes to read

An MQTT broker can be used to monitor your Node data and to send DM messages to the Gateway. You can easily setup an MQTT broker on your computer for testing or configuration purposes. For example, Mosquitto can be used for that purpose on Windows 10:

  1. Download and install Mosquitto on your computer. On Windows it will attempt to install to Program files, that means you’ll need admin rights to edit the configuration files and use some of the commands.

  2. Navigate to the installation folder and create a configuration file (example treon.conf)

per_listener_settings true
listener 1883
password_file  C:\Program Files\mosquitto\pswd.conf
  1. Navigate to the installation folder and open command prompt on it (admin rights might be needed).

  2. Create password file (example pswd.conf) user is the username you want to create. Then type the password twice.

mosquitto_passwd -c pswd.conf user
  1. Mosquitto MQTT broker can be started using command
mosquitto -v -c treon.conf
  1. Open another command prompt window and type
ipconfig

and find your computer’s IP address on the local network.

  1. Enable an MQTT connection from your Gateway through the Config UI configuration mode. Type your computer’s IP address and port, as well as user and password, and enable insecure connection.

  2. Open another command prompt window on your computer to subscribe to the MQTT broker by typing in:

mosquitto_sub -L mqtt(s)://[username[:password]@]host[:port]/topic
mosquitto_sub -L mqtt://user:pswd@192.168.1.123:1883/treon/devices/1234abcd

Replace the host and password values. Replace ‘host’ with your computer’s IP address and replace ‘topic’ with your Gateway’s MQTT publishing topic. By default it is:

treon/devices/ID/#

and replace ‘ID’ with your Gateway’s device ID. Now you can see the incoming messages in real time.


Was this article helpful? Let us know.
Previous