😎 κ³΅λΆ€ν•˜λŠ” μ§•μ§•μ•ŒνŒŒμΉ΄λŠ” μ²˜μŒμ΄μ§€?

[MQTT] (2) docker image λ§Œλ“€κΈ° & MQTT json λ©”μ‹œμ§€ λ°œν–‰ 및 κ΅¬λ…ν•˜κΈ° λ³Έλ¬Έ

πŸ‘©‍πŸ’» λ°±μ—”λ“œ(Back-End)/Protocol & Web

[MQTT] (2) docker image λ§Œλ“€κΈ° & MQTT json λ©”μ‹œμ§€ λ°œν–‰ 및 κ΅¬λ…ν•˜κΈ°

μ§•μ§•μ•ŒνŒŒμΉ΄ 2023. 5. 8. 00:49
728x90
λ°˜μ‘ν˜•

<λ³Έ λΈ”λ‘œκ·ΈλŠ” μ—˜λ¦¬μŠ€ IoT 1λ₯Ό μ°Έκ³ ν•΄μ„œ κ³΅λΆ€ν•˜λ©° μž‘μ„±ν•˜μ˜€μŠ΅λ‹ˆλ‹€ :-)>

(μ½”λ“œλŠ” μ €μž‘κΆŒμƒ 곡유 μ•ˆλ©λ‹ˆλ‹Ή!!)

 

β˜€οΈ docker image λ§Œλ“€κΈ°

npm init ν•˜κ΅¬μš©

config, data, log 폴더λ₯Ό λ§Œλ“­λ‹ˆλ‹€.

 

🌠 docker-compose.yaml

version : "3.8"
services :
  mosquitto:
    image: "eclipse-mosquitto"
    ports:
      - "1883:1883"
      - "9001:9001"
    volumes:
      - ./config/mosquitto.conf:/mosquitto/config/mosquitto.conf
      - ./data:/mosquitto/data
      - ./log:/mosquitto/log
    restart: always

 

🌠 config/mosquitto.conf

persistence false
allow_anonymous true
connection_messages true
log_type all
listener 1883

 

🌠 docker image μ‹€ν–‰ν•˜κΈ°

sudo docker-compose up

 

🌠 νŒ¨ν‚€μ§€ μ„€μΉ˜

npm install mqtt

 

🌠 mqtt json λ©”μ‹œμ§€ λ°œν–‰ 및 κ΅¬λ…ν•˜κΈ°

λ‘κ°œμ˜ bash μ—΄μ–΄μ„œ λ°‘ λͺ…λ Ήμ–΄ μ‹€ν–‰ν•˜κΈ°

node subscriber.js
node publish.js

728x90
λ°˜μ‘ν˜•
Comments