-
Notifications
You must be signed in to change notification settings - Fork 1
MQTT Testing
Fyzel edited this page Sep 8, 2018
·
2 revisions
In order to confirm that the MQTT configuration on the Raspberry Pi functions as expected, perform the following tasks.
-
On the Local MQTT Broker, enable the
logging all
option in/etc/mosquitto/conf.d/default.config
to troubleshoot the connection. -
Restart Mosquitto.
sudo service mosquitto stop && sudo service mosquitto start
- tail the Mosquitto log to trace the debugging messages.
sudo tail -f /var/log/mosquitto/mosquitto.log
- Connect a MQTT subscriber to the Local MQTT Broker. Specify the QOS as 2, the test topic, and the username and password.
mosquitto_sub -h localhost -p 1883 -q 2 -t "test" -u "weather-api-user" -P "secret"
- A test message can be queued to the Local MQTT Broker to confirm local communication.
mosquitto_pub -h localhost -p 1883 -t "test" -m "hello password protected world" -u "weather-api-user" -P "secret" -d
This will result in the message hello password protected world in the subscriber's output.
- The Remote MQTT Broker's connectivity can be confirmed by running
mosquitto_sub
on the remote server or installing mqtt-spy and connecting remotely.
There may be a slight delay between the bridged messages.