In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to parse mosquitto_sub and mosquitto_pub command parameters. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
1) Open a terminal to subscribe to the message: mosquitto_sub-v-t "test/topic" 2) open another terminal to publish the message: mosquitto_pub-t "test/topic"-m 'hello world'3) after publishing the message, you can see the subscribed message on the subscriber side: test/topic hello worldmosquitto_sub parsing:
Mosquitto_sub is the command run by the subscriber terminal,-v is to print details,-t is the topic to be subscribed to, followed by the topic, where the topic is called test/topic.
Mosquitto_pub is the command run by the publishing terminal,-t is the topic to be published, followed by the topic,-m is the content to be published, followed by the parameter is the content to be published, where the value is hello world.
For the specific MQTT command implementation method, students who are interested can check the source code for themselves. The source code is under the Mosquitto-1.4.5 / client directory, and the directory file is as follows:
Client_shared.c CMakeLists.txt mosquitto_sub sub_client.c
Client_shared.h Makefile pub_client.c sub_client.o
Client_shared.o mosquitto_pub pub_client.o
The main implementation of the command is implemented in the three files client_shared.c, pub_client.c and sub_client.c, in which pub_client.c implements the publishing function, sub_client.c realizes the subscription function, and client_shared.c is the common part of the previous two c files.
Mosquitto_pub command parameter description
-d print debug information
-f takes the contents of the specified file as the contents of the message to be sent
-h specifies that the domain name to be connected defaults to localhost
-I specify which clientId user to send the message to
-I specify which clientId prefix user to send the message to
-m message content
-n send an null message
-p connection port number
-Q specifies the value of QoS (0re1jpg2)
-t specify topic
-u specify broker access user
-P specify the broker access password
-V specifies the MQTT protocol version
-- will-payload specifies a message that is sent when the client is accidentally disconnected from the broker. This parameter needs to be used with-- will-topic
-- the QOS value of will-qos Will. This parameter needs to be used with-- will-topic
-- will-retain specifies that the Will message is treated as a retain message (that is, after the message is broadcast, the message is retained). This parameter needs to be used with-- will-topic
-- topic on which will-topic users send Will messages
Mosquitto_sub command parameter description
-c sets the 'clean session' to be invalid so that it remains subscribed all the time, even if the connection has been lost, and the message sent during the disconnection can still be received if the connection is reconnected.
-d print debug information
-h specifies that the domain name to be connected defaults to localhost
-I specify clientId
-I specify the clientId prefix
-k keepalive sends PING messages to inform broker that it is still connected from time to time. The default is 60 seconds.
-Q specifies why you want to receive QoS messages. The default QoS is 0.
-R does not display stale messages
-t subscribe to topic
-v print message
-- will-payload specifies a message that is sent when the client is accidentally disconnected from the broker. This parameter needs to be used with-- will-topic
-- the QOS value of will-qos Will. This parameter needs to be used with-- will-topic
-- will-retain specifies that the Will message is treated as a retain message (that is, after the message is broadcast, the message is retained). This parameter needs to be used with-- will-topic
-- topic on which will-topic users send Will messages
On how to parse mosquitto_sub, mosquitto_pub command parameters to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.