Upgrade to Pro — share decks privately, control downloads, hide ads and more …

「MQTT完全に理解した」から一歩踏み出してみた / Learning MQTT beyond copy-paste habit

「MQTT完全に理解した」から一歩踏み出してみた / Learning MQTT beyond copy-paste habit

IoTLT vol.53の発表資料
タイトル:「MQTT完全に理解した」から一歩踏み出してみた

386cb4a00138384e4f584ac791aaf141?s=128

Shingo Fukui

July 19, 2019
Tweet

Transcript

  1. COPYRIGHT ©2019 SHINGO FUKUI ʮMQTT ׬શʹཧղͨ͠ʯ͔Β Ұา౿Έग़ͯ͠Έͨ 2019೥7݄19೔ IoTറΓͷษڧձ! IoTLT

    vol.53 @LINE ෱Ҫ ᚸޗ
  2. COPYRIGHT ©2019 SHINGO FUKUI ࣗݾ঺հ ෱Ҫᚸޗ @SilkAndTikit ιϑτ΢ΣΞΤϯδχΞʢJavaScript, Java, ,

    Lisp, Cʣ IoTΤϯδχΞʹస޲தɹ 2 IoTϋϯζΦϯ։࠵ ࣗಈਫ΍Γػ৬ਓ https://iot-gym.connpass.com ຊͷ຋༁
  3. COPYRIGHT ©2019 SHINGO FUKUI ए͍ਓʹΑ͘આڭ͍ͯͨ͠ 3 QiitaͷίϐϖͰ΍Γաͯͨ͝͠Β੒௕͠ͳ͍Αɻ ͪΌΜͱجຊͷ࢓૊ΈΛֶ͹ͳͪ͘Όɻ ࿝֐

  4. COPYRIGHT ©2019 SHINGO FUKUI ͦΕͳͷʹɺ ɹMQTTͷίʔυΛίϐϖͯ͠ࡁ·͍ͤͯͨʂ 4

  5. COPYRIGHT ©2019 SHINGO FUKUI MQTT
 Broker ίϐϖͰ΋MQTTͷجຊ͸Θ͔ͬͨ 5 MQTT Client

    ϓϩτίϧ͕ܰྔͰIoTʹ޲͍͍ͯΔ ొ৔ਓ෺͸ Broker ͱ Client Publish / Subscribe ܕ௨৴ MQTT Client Topic A Topic B "Hello" Publisher Subscriber Publish "Hello" to B
  6. COPYRIGHT ©2019 SHINGO FUKUI ίϐϖ͚ͩͩͱ
 ɹΘ͔Βͳ͍͜ͱ͕৭ʑग़͖ͯͨ ͲͷBrokerɺͲͷClientιϑτΛ࢖͏͔ʁ ϒϥ΢βͰMQTT௨৴͢Δํ๏͸ʁ ར༻ऀΛݶఆ͢Δํ๏͸ʁ Node-RedͰMQTTΛར༻͢Δํ๏͸ʁ

    6 ͦ͜ͰɺجຊΛֶΜͰΈͨ ͍͔ͭ͘঺հ
  7. COPYRIGHT ©2019 SHINGO FUKUI MQTTͷ௨৴ͷछྨ 7 TCP઀ଓɹmqtt://αʔόΞυϨε:1883/ Client Broker TCP

  8. COPYRIGHT ©2019 SHINGO FUKUI MQTTͷ௨৴ͷछྨ 8 TCP઀ଓɹmqtt://αʔόΞυϨε:1883/ Client WebSocket઀ଓɹws://αʔόΞυϨε:9001/ ϒϥ΢β

    JavaScript Broker Broker WebSocket TCP
  9. COPYRIGHT ©2019 SHINGO FUKUI ҉߸Խͳ͠ MQTTͷ௨৴ͷछྨ 9 TCP઀ଓɹmqtt://αʔόΞυϨε:1883/ Client WebSocket઀ଓɹws://αʔόΞυϨε:9001/

    ϒϥ΢β JavaScript Broker Broker WebSocket TCP
  10. COPYRIGHT ©2019 SHINGO FUKUI ҉߸Խͳ͠ MQTTͷ௨৴ͷछྨ 10 TCP઀ଓɹmqtt://αʔόΞυϨε:1883/ Client WebSocket઀ଓɹws://αʔόΞυϨε:9001/

    ϒϥ΢β JavaScript Broker Broker TLS҉߸Խ Client WebSocket઀ଓɹwss://αʔόΞυϨε:443/ ϒϥ΢β JavaScript Broker Broker WebSocket
 + TLS TCP+TLS TCP઀ଓɹmqtts://αʔόΞυϨε:8883/ WebSocket TCP
  11. COPYRIGHT ©2019 SHINGO FUKUI ར༻ऀೝূͷछྨ ೝূͳ͠ʢanonymousʣ ID, PASSWORDͰೝূ ʢClientূ໌ॻͰೝূʣ 11

  12. COPYRIGHT ©2019 SHINGO FUKUI ௨৴ͷछྨͷશύλʔϯ 2 x 2 x 2

    = 8ύλʔϯ 12 TCP WebSocket ҉߸Խͳ͠ TLS Clientೝূͳ͠ ID, PASSWORD X X ஫ɿClientূ໌ॻ͸লུ
  13. COPYRIGHT ©2019 SHINGO FUKUI ࣮ݧͷਐΊํ: 1εςοϓͣͭෳࡶԽ 13 MQTT.js mosquitto mosquitto

    TCP TCP Client Broker ID,PW MQTT.js ID,PW TCP mosquitto MQTT.js mosquitto WebSocket WebSocket WebSocket TLS MQTT.js TLS TCP+TLS mosquitto 1. 2. 3. 4. 5.
  14. COPYRIGHT ©2019 SHINGO FUKUI Node-RedͰMQTT Clientͱͯ͠࢖͍͍ͨ BrokerΛNode-Red಺Ͱಈ͔͍ͨ͠ 14

  15. COPYRIGHT ©2019 SHINGO FUKUI PublishϊʔυɺSubscribeϊʔυΛ࢖͏ Clientͱͯ͠࢖͍͍ͨ 15 MQTT
 Broker subscribe

    publish
  16. COPYRIGHT ©2019 SHINGO FUKUI PublishϊʔυɺSubscribeϊʔυΛ࢖͏ Clientͱͯ͠࢖͍͍ͨ 16 MQTT
 Broker subscribe

    publish Node-RedͱBrokerΛηοτͰఏڙ͢Δ
 Ϋϥ΢υαʔϏε΋͋Δ
  17. COPYRIGHT ©2019 SHINGO FUKUI Node-Red಺ͰBrokerΛಈ͔͍ͨ͠ 17 node.jsͰॻ͔ΕͨMQTT Broker ʮMoscaʯ͕ϊʔυͱͯ͠ಈ͘ ʮύϨοτͷ؅ཧʯͰnode-red-contrib-mqtt-brokerΛ௥Ճ͢Δ

    TCP , WebSocket྆ରԠɻID,PASSWORD͸? TLS͸ʁ Node-RedαʔόʔͷMQTTϙʔτ͕ղ์͞Ε͍ͯΕ͹֎෦ػثͱ௨৴Ͱ͖Δ subscribe publish Broker
  18. COPYRIGHT ©2019 SHINGO FUKUI جຊΛֶͿ͜ͱ͸େࣄʂ 18

  19. COPYRIGHT ©2019 SHINGO FUKUI ݁࿦ɿ͜Ε͔Β΋આڭΛଓ͚Δ 19 ϝϯλʔ ࿝֐ QiitaͷίϐϖͰ΍Γաͯͨ͝͠Β੒௕͠ͳ͍Αɻ ͪΌΜͱجຊͷ࢓૊ΈΛֶ͹ͳͪ͘Όɻ