- apt install mosquitto mosquitto-clients -y
- mosquitto_sub -h localhost -t test
- mosquitto_pub -h localhost -t test -m "Hello World"
- mosquitto_sub -h localhost -t test
Default Port : 1883
- sudo mosquitto_passwd -c /etc/mosquitto/passwd admin
- sudo nano /etc/mosquitto/conf.d/default.conf
- copy these lines to the file
allow_anonymous false
password_file /etc/mosquitto/passwd
- sudo systemctl restart mosquitto
- mosquitto_sub -h localhost -t test -u "admin" -P "password"
- mosquitto_pub -h localhost -t "test" -m "Hello World" -u "admin" -P "password"
- pip3 install paho-mqtt
- apt install python3-paho-mqtt -y