MQTT ブローカー
An MQTT broker is a server that receives all client messages and then routes the messages to the appropriate destination clients. An MQTT client is any device (from a microcontroller up to a fully-fledged server) that runs an MQTT library and connects to an MQTT broker over a network.
An open-source MQTT broker, LEAPS Mosquitto is a copy of docker image eclipse-mosquitto:1.5.11 with integrated custom mosquitto.conf
file located in /mosquitto/config/mosquitto.conf
.
For additional information, please see eclipse-mosquitto
インストール
System requirements
注釈
Dockerのシステム要件はOSによって異なります。
Linuxの場合、64ビット・アーキテクチャ、互換性のあるカーネル・バージョン、特定のカーネル機能が必要だ。
Windowsでは、仮想化を有効にしたWindows 10上でDocker Desktopを使用します
macOSの場合は、macOS 10.13以降のDocker Desktopを使用してください。ハードウェアに関しては、最低2GBのRAMと十分なCPUとディスク容量を推奨します。
最新の詳細については`Docker <https://docs.docker.com/>`_公式ドキュメントを参照してください。
使用方法
PCにDockerをインストールする
さらに、以下のコマンドを参考にしてインストールすることもできる:
curl -fsSL https://get.docker.com -o get-docker.sh sudo sh ./get-docker.sh sudo usermod -aG docker $USER
Open a command prompt or terminal window on your PC, then install the LEAPS Mosquitto Docker packages, run:
docker run -d -p 1883:1883/tcp -p 15675:15675 --name some_name leapslabs/leaps_mosquitto:latest mosquitto ---cfg /mosquitto/config/mosquitto.conf
where
some_name
is the name you want to assign to your container andtag
is the tag specifying theleaps-mosquitto
version you want.
推奨される走行オプション
--user $(id -u):$(id -g)
特定のユーザーとグループの下でインスタンスを実行する。
--restart unless-stopped
サーバーがクラッシュした場合にインスタンスを自動的に再起動する。
The LEAPS Mosquitto installation process will begin.
たとえば、Ubuntu (Linux) の場合:
docker run -d -p 1883:1883/tcp -p 15675:15675 --name leaps_mosquitto leapslabs/leaps_mosquitto:latest mosquitto ---cfg /mosquitto/config/mosquitto.conf Unable to find image 'leapslabs/leaps_mosquitto:latest' locally latest: Pulling from leapslabs/leaps_mosquitto f7dab3ab2d6e: Already exists 2a0a6c9fa787: Already exists a211eff771d6: Already exists d362e2a9c11b: Already exists Digest: sha256:a97752d6e2d81e2701c7cd5f807eb4256322983f8aa3135da8235b647e6a9b4e Status: Downloaded newer image for leapslabs/leaps_mosquitto:latest 1f526e755ad9a356c439003b93c200802628ae9bc046827e7327d0334804b565
インストールが成功したことを確認し、実行する:
たとえば、Ubuntu (Linux) の場合:
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b1145b72db35 leapslabs/leaps_mosquitto:latest "sh -c 'cd /app && …" 37 seconds ago 11 seconds ago leaps_mosquitto
So, you have successfully installed and started LEAPS Mosquitto on your PC.
Getting started
LEAPS Mosquitto Docker
Start LEAPS Mosquitto, run:
docker start leaps_mosquitto
Stop LEAPS Mosquitto, run:
docker stop leaps_mosquitto
Restart LEAPS Mosquitto, run:
docker restart leaps_mosquitto
Remove LEAPS Mosquitto, run
docker rm --force leaps_mosquitto
Customized options
Mandatory options
port 1883 - default listener port
listener 1884 enabling listener at 1884
listener 15675 enabling listener at 15675
Recommended options
user mosquitto - Drop root priviledges
max_inflight_messages 200 - increase infighting QoS messages per client as few QoS1 could be sent at once.
max_queued_messages 1000 - increase the maximum number of QoS 1 and 2 messages to hold in a queue per client above those currently in-flight.
allow_zero_length_clientid true - allow client ID to be zero lenghth
persistent_client_expiration 14d - Auto protection from poorly designed clients
トラブルシューティング
Use the following command
docker restart leaps_mosquitto
to restart LEAPS Mosquitto.Check the logs when the LEAPS Mosquitto is running, open the docker desktop, and select the leaps_mosquitto container.