Simple setting and implementation of mqtt mosquitto bridge

bridge settings

Under Linux, the configuration file of mosquitto is the /etc/mosquitto/mosquitto.conf file. The modification of this file requires root privileges. Therefore, I usually copy this file to a file under the home file to modify the bridge configuration.

  1. Copy the mosquitto.conf file;
  2. Add the following code at the end of the mosquitto.conf file
connection test
address xxx.xxx.xxx.xxx:yyyy
topic # in 1

Among them, connection represents a connection, and the following test represents the name of the connection (you can modify it according to your needs); xxx in address is the ip address, yyyy is the port number; # in topic is the wildcard of topic, also That is, all topics are bridged, and you can also change # to the topic you need according to your needs. in means only bridge received topic data, and out means only bridge sent topic data, and both means sent and received data Both are bridged, 1 represents the qos value (can be modified to 0, 1, 2 according to your needs);

Instructions to start the bridge

mosquitto -c xxx/mosquitto.conf -p 5678 -v

Among them, -c specifies the configuration file used by mosquitto, followed by the location of the configuration file. If you modify the configuration file under /etc/mosquitto/, you can set it here, because the mosquitto command will default Use this configuration file;

おすすめ

転載: blog.csdn.net/u012850592/article/details/103406966