EMQ Learn---Subscribe to the $sys topic to capture the client's downline messages

Source: Internet
Author: User

The Acl.config file defines the permissions that can be subscribed to $sys topics .

{Allow, {user, ' dashboard '}, subscribe, ["$SYS/#"]}. {Allow, {ipaddr, ' 127.0.0.1 '}, PubSub, ["$SYS/#", "#"]}.%%%{deny, all, subscribe, ["$SYS/#", {eq, "#"}]}. {Allow, all}.

The third line of the Acl.config file is by default preventing clients from subscribing to $sys/#主题. We'll comment it out. Open a client and subscribe to the $sys/#主题 with the following message:

Module (emqttd_broker), which will publish messages per second, subject keywords are uptime and datetime.

Module (emqttd_stats), which publish messages every 60 seconds, sends out the information mqtt_stats the ETS table.

Module (emqttd_metrics), which is the same principle.

eg

$SYS/brokers/[email protected]/uptime:qos=0

$SYS/brokers/[email protected]/sysdescr:qos=0

Open the file Vm.args and modify the node name to:

#-name [email protected]-name [email protected]

eg

$SYS/brokers/[email protected]/uptime:qos=0

$SYS/brokers/[email protected]/sysdescr:qos=0

Topics for subscribing to a client's top-down line

The subject of a specific ClientID method for a particular node is:

$SYS/brokers/(node)/clients/(clientId)/connected$sys/brokers/[email protected]/clients/861694030142478/ Connected$sys/brokers/[email protected]/clients/861694030142478/disconnected

The theme of the wildcard method is:

$SYS/brokers/+/clients/+/connected$sys/brokers/+/clients/+/disconnected$sys/brokers/+/clients/#

For security reasons, we modified the Acl.config file to:

Allow clients to subscribe to the "$SYS/brokers/+/clients/#" topic, but not subscribe to the "$SYS/#" topic.

{Allow, {user, ' dashboard '}, subscribe, ["$SYS/#"]}. {Allow, {ipaddr, "127.0.0.1"}, PubSub, ["$SYS/#", "#"]}. {Allow, all, subscribe, ["$SYS/brokers/+/clients/#"]}. {Deny, all, subscribe, ["$SYS/#", {eq, "#"}]}. {Allow, all}.

  



EMQ Learn---Subscribe to the $sys topic to capture the client's downline messages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.