Mosquitto
An Open Source MQTT v3.1 Broker
- Mosquitto is an open source message broker
- implements the MQTT protocol version 3.1.
- Client API programming languages
: C/C++
: Python
: JS with WebSocket
- BSD License
* Facebook using MQTT
[Sample compile & run]
- Server
cc@cc-System:~$ tar zxvf mosquitto-1.1.3.tar.gz
cc@cc-System:~$ cd mosquitto-1.1.3/
cc@cc-System:~/mosquitto-1.1.3$ ls
aclfile.example client compiling.txt config.mk installer LICENSE-3rd-party.txt logo man mosquitto.conf pwfile.example readme-windows.txt service test
ChangeLog.txt CMakeLists.txt config.h examples lib LICENSE.txt Makefile misc pskfile.example readme.txt security src
cc@cc-System:~/mosquitto-1.1.3$ make
set -e; for d in lib client src; do make -C ${d}; done
make[1]: Entering directory `/home/cc/mosquitto-1.1.3/lib'
cc -Wall -ggdb -O2 -I. -I.. -I../lib -fPIC -DWITH_TLS -DWITH_TLS_PSK -DWITH_THREADING -c mosquitto.c -o mosquitto.o
cc -Wall -ggdb -O2 -I. -I.. -I../lib -fPIC -DWITH_TLS -DWITH_TLS_PSK -DWITH_THREADING -c logging_mosq.c -o logging_mosq.o
cc mosquitto.o bridge.o conf.o context.o database.o logging.o loop.o memory_mosq.o persist.o net.o net_mosq.o read_handle.o read_handle_client.o read_handle_server.o read_handle_shared.o security.o security_default.o send_client_mosq.o send_mosq.o send_server.o service.o subs.o util_mosq.o will_mosq.o -o mosquitto -ldl -lm -lssl -lcrypto
cc -Wall -ggdb -O2 -c mosquitto_passwd.c -o mosquitto_passwd.o
cc mosquitto_passwd.o -o mosquitto_passwd -lcrypto
make[1]: Leaving directory `/home/cc/mosquitto-1.1.3/src'
set -e; for d in man; do make -C ${d}; done
make[1]: Entering directory `/home/cc/mosquitto-1.1.3/man'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/cc/mosquitto-1.1.3/man'
cc@cc-System:~/mosquitto-1.1.3$ cd src/
cc@cc-System:~/mosquitto-1.1.3/src$ ./mosquitto
1367887027: mosquitto version 1.1.3 (build date 2013-05-07 09:36:34+0900) starting
1367887027: Using default config.
1367887027: Opening ipv4 listen socket on port 1883.
1367887027: Opening ipv6 listen socket on port 1883.
|
- Client
- client application을 실행하려면 mosquitto library 경로(mosquitto-1.1.3/lib)를 ldconfig에서 인식하도록 /etc/ld.so.conf.d/ 에 configuration을 저장 해줘야 한다.
- client 폴더의 mosquitto_pub, mosquitto_sub 를 실행하면 되고 관련 설명은 아래 참고
- client 폴더의 mosquitto_pub, mosquitto_sub 를 실행하면 되고 관련 설명은 아래 참고
- mosquitto_sub(1) – command line client for subscribing
- 서버 실행
cc@cc-System:~/mosquitto-1.1.3/src$ ./mosquitto
1367891704: mosquitto version 1.1.3 (build date 2013-05-07 09:36:34+0900) starting
1367891704: Using default config.
1367891704: Opening ipv4 listen socket on port 1883.
1367891704: Opening ipv6 listen socket on port 1883.
1367893254: New connection from 127.0.0.1.
1367893254: New client connected from 127.0.0.1 as mosqsub/16299-cc-Sys.
1367893308: New connection from 127.0.0.1.
1367893308: New client connected from 127.0.0.1 as mosqpub/16317-cc-Sys.
1367893333: New connection from 127.0.0.1.
1367893333: New client connected from 127.0.0.1 as mosqpub/16391-cc-Sys.
1367893360: New connection from 127.0.0.1.
1367893360: New client connected from 127.0.0.1 as mosqsub/16406-cc-Sys.
1367893367: New connection from 127.0.0.1.
1367893367: New client connected from 127.0.0.1 as mosqpub/16408-cc-Sys.
1367893373: New connection from 127.0.0.1.
1367893373: New client connected from 127.0.0.1 as mosqpub/16409-cc-Sys.
|
- publish
cc@cc-System:~/mosquitto-1.1.3/client$ ./mosquitto_pub -t sensors/temperature -m 32 -q 1
cc@cc-System:~/mosquitto-1.1.3/client$ ./mosquitto_pub -t sensors/temperature -m 34 -q 1
cc@cc-System:~/mosquitto-1.1.3/client$ ./mosquitto_pub -t sensors/temperature -m 35 -q 1
cc@cc-System:~/mosquitto-1.1.3/client$ ./mosquitto_pub -t sensors/temperature -m 38 -q 1
cc@cc-System:~/mosquitto-1.1.3/client$
|
cc@cc-System:~/mosquitto-1.1.3/client$ ./mosquitto_sub -t sensors/temperature -q 1
32
34
35
38
|
cc@cc-System:~/mosquitto-1.1.3/client$ ./mosquitto_sub -t sensors/temperature -q 1
35
38
|
역시.. 분석은 나중에..
댓글 없음:
댓글 쓰기