Linux/Mosquitto: Difference between revisions
< Linux
No edit summary |
m (→Bridge) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Basic usage == | |||
* subscribe | |||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
Line 8: | Line 8: | ||
</pre> | </pre> | ||
</blockquote> | </blockquote> | ||
* publish | |||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
Line 17: | Line 17: | ||
</blockquote> | </blockquote> | ||
== User == | |||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
Line 24: | Line 23: | ||
</pre> | </pre> | ||
</blockquote> | </blockquote> | ||
= Config = | |||
* get mosquitto.conf from docker container | |||
<pre> | |||
docker cp mosquitto:/mosquitto/config/mosquitto.conf . | |||
</pre> | |||
== Simple broker == | |||
<pre> | |||
allow_anonymous true | |||
listener 1883 | |||
persistence true | |||
persistence_location /mosquitto/data/ | |||
log_dest file /mosquitto/log/mosquitto.log | |||
</pre> | |||
== Bridge == | |||
* Only configure on slave brokers. No special config on maste broker. | |||
* quick reference | |||
<pre> | |||
topic {topic pattern} direction QOS {local prefix} {remote prefix} | |||
topic # in 0 | |||
topic edge/# out 1 | |||
topic # out 2 tocloud/ fromedge/ | |||
</pre> | |||
* Basic 1:1 bridge | |||
<pre> | |||
... | |||
connection cloudvm | |||
address 10.10.0.1:1883 | |||
try_private true | |||
topic # out 0 | |||
topic # in 0 | |||
</pre> | |||
* only slave topics are shared | |||
<pre> | |||
... | |||
connection cloudvm | |||
address 10.10.0.1:1883 | |||
try_private true | |||
topic edge/# out 0 | |||
topic edge/# in 0 | |||
</pre> | |||
== Links == | |||
* https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices | |||
* http://www.iotsharing.com/2017/08/how-to-use-esp32-mqtts-with-mqtts-mosquitto-broker-tls-ssl.html | |||
[[Category:Linux/Services]] | |||
[[Category:Linux]] |
Latest revision as of 21:11, 2 December 2023
Basic usage
- subscribe
mosquitto_sub -t "test" -h servername mosquitto_sub -t "test" -h servername -u "username" -P "password" mosquitto_sub -t "test" -h servername -u "username" -P "password" -p 8883 --capath /etc/ssl/certs/
- publish
mosquitto_pub -t "test" -m "test message" -h servername mosquitto_pub -t "test" -m "test message" -h servername -u "username" -P "password" mosquitto_pub -t "test" -m "test message" -h servername -u "username" -P "password" -p 8883 --capath /etc/ssl/certs/
User
mosquitto_passwd /etc/mosquitto/users BENUTZERNAME
Config
- get mosquitto.conf from docker container
docker cp mosquitto:/mosquitto/config/mosquitto.conf .
Simple broker
allow_anonymous true listener 1883 persistence true persistence_location /mosquitto/data/ log_dest file /mosquitto/log/mosquitto.log
Bridge
- Only configure on slave brokers. No special config on maste broker.
- quick reference
topic {topic pattern} direction QOS {local prefix} {remote prefix} topic # in 0 topic edge/# out 1 topic # out 2 tocloud/ fromedge/
- Basic 1:1 bridge
... connection cloudvm address 10.10.0.1:1883 try_private true topic # out 0 topic # in 0
- only slave topics are shared
... connection cloudvm address 10.10.0.1:1883 try_private true topic edge/# out 0 topic edge/# in 0