Server/MQTT

[MQTT] Mosquitto 설치 및 Publishr/Subscriber 테스트

히진 2018. 9. 2. 01:18
반응형


Mosquitto 설치 - Linux / Local


Mosquitto Download / install

$ wget http://mosquitto.org/files/source/mosquitto-1.4.2.tar.gz

$ tar –xvf mosquitto-1.4.2.tar.gz

$ cd mosquito-1.4.2

$ make

$ sudo make install



Shared library 등록

$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

$ sudo ldconfig /usr/local/libmake


실행 

mosquito (root 실행 X - mosquito는 root 실행을 권장하지 않습니다.)






Mosquitto 설치 - Linux / Docker


Mosquitto Dockerhub url 

https://hub.docker.com/_/eclipse-mosquitto/


Mosquitto Download / install


$ docker pull eclipse-mosquitto

$ mkdir /mosquitto/config

$ mkdir /mosquitto/data

$ mkdir /mosquitto/log

$ vim /mosquitto/config/mosquitto.conf 

  :wq!

vim /mosquitto/log/mosquitto.log

  :wq!

$ docker run -it -p 1883:1883 -p 9001:9001 -v mosquitto.conf:/mosquitto/config/mosquitto.conf -v /mosquitto/data -v /mosquitto/log eclipse-mosquitto

$ docker ps - a





Publishr / Subscriber Test


1. Subscriber App Test [구독]

1. Playstore MQTT Cliner App Download 



2. Host 입력 후 Subscribe Topic 입력



2. Subscriber Mosquitto Test [구독]

$ cd /mosquito-1.4.2/client

$ mosquitto_sub -h 127.0.0.1 -t HelloWorld -p1883 (Topic구독)
-option 
-h : Host 
-t : Topic 
-p : Port



3. Publisher Mosquitto Test [발행]

$ cd /mosquito-1.4.2/client

$ mosquitto_pub -h 127.0.0.1 -t HelloWorld -m "MQTT Publish Test" (메세지 발행)



4.Subscriber 확인

1. App 확인



2. Mosquitto 확인


MQTT의 개념 및 설명

http://khj93.tistory.com/entry/MQTT-MQTT%EC%9D%98-%EA%B0%9C%EB%85%90

반응형