[ Broker ] 在 Ubuntu 安裝 Mosquitto MQTT Broker

學習目標

  • Mosquitto MQTT Broker 安裝

前置準備作業

  1. Ubuntu 電腦

Ubuntu 端

Step 1. 安裝 Mosquitto MQTT Broker

❖ 1.1  開啟終端機


❖ 1.2  取得遠端更新伺服器的套件檔案清單
       sudo apt update


❖ 1.3  安裝 Mosquitto MQTT Broker
       sudo apt install -y mosquitto


❖ 1.4  安裝 Mosquitto Client
       sudo apt install -y mosquitto-clients


Step 2. 測試 Mosquitto MQTT Broker

【 示意圖 】
Subscriber 向 Mosquitto MQTT Broker 訂閱 Sensor/Temperature/Room1 的 Topic,Publisher 產生 Topic 為 Sensor/Temperature/Room1 的 hello world 訊息  

❖ 2.1  建立 Subscriber
       mosquitto_sub -h IP -t Topic
       e.g., mosquitto_sub -h 10.211.55.9 -t Sensor/Temperature/Room1


❖ 2.2  建立 Publisher
       mosquitto_pub -h IP -t Topic -m Message
       e.g., mosquitto_pub -h 10.211.55.9 -t Sensor/Temperature/Room1 -m "hello world"


❖ 2.3  Subscriber 接收到的資訊


Reference
GitHub
List of blogs
ALL RIGHTS RESERVED. COPYRIGHT © 2018. Designed and Coded by Makee.io