Linux/Mosquitto: Difference between revisions

From Wiki
mNo edit summary
Line 29: Line 29:
docker cp mosquitto:/mosquitto/config/mosquitto.conf .
docker cp mosquitto:/mosquitto/config/mosquitto.conf .
</pre>
</pre>
== simple broker ==
== Simple broker ==
<pre>
<pre>
allow_anonymous true
allow_anonymous true
Line 38: Line 38:
</pre>
</pre>


== bridge ==
== Bridge ==
* Only configure on slave brokers. No special config on maste broker.
 
* Basic 1:1 bridge
<pre>
...
connection cloudvm
address 10.10.0.1:1883
topic # out 0
topic # in 0
</pre>
 
* only slave topics are shared
<pre>
...
connection cloudvm
address 10.10.0.1:1883
topic edge/# out 0
topic edge/# in 0
</pre>
 





Revision as of 20:45, 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.
  • Basic 1:1 bridge
...
connection cloudvm
address 10.10.0.1:1883
topic # out 0
topic # in 0
  • only slave topics are shared
...
connection cloudvm
address 10.10.0.1:1883
topic edge/# out 0
topic edge/# in 0


Links