MQTT Mosquitto Websockets

สมมุติว่า port mqtt คือ 8883 และ websocket คือ 8083

sudo nano  /etc/mosquitto/mosquitto.conf



  GNU nano 5.4                                /etc/mosquitto/mosquitto.conf

# Place your local configuration in /etc/mosquitto/conf.d/


# A full description of the configuration file is at

# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

per_listener_settings true

pid_file /run/mosquitto/

persistence true

persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

connection_messages true

log_timestamp true

log_timestamp_format %Y-%m-%dT%H:%M:%S

include_dir /etc/mosquitto/conf.d

#allow_anonymous false

listener 8883

protocol mqtt

allow_anonymous false

password_file /etc/mosquitto/passwordfile

listener 9001

protocol websockets

allow_anonymous false

password_file /etc/mosquitto/passwordfile

#socket_domain ipv4

passwordfile example


encrypt file

sudo mosquitto_passwd -U passwordfile