publish-subscribe - Mosquitto 未在 SYS 主题上发布

标签 publish-subscribe mqtt mosquitto

我使用 mosquitto 服务器作为 mqtt 代理。我正在测试 mosquitto 的性能,我需要订阅 $SYS 层次结构以获取一些数据,例如从 $SYS/broker/clients/active 当前连接的数量话题。我有以下 mosquitto 配置文件。

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

listener 1884
protocol websockets

listener 1883

sys_interval 1

max_connections -1

我正在订阅 $SYS/broker/clients/active这样的话题
ubuntu@linux-box:/etc/mosquitto$ mosquitto_sub -d -t $SYS/broker/clients/active
Client mosqsub/28715-ip-172-31 sending CONNECT
Client mosqsub/28715-ip-172-31 received CONNACK
Client mosqsub/28715-ip-172-31 sending SUBSCRIBE (Mid: 1, Topic: /broker/clients/active, QoS: 0)
Client mosqsub/28715-ip-172-31 received SUBACK
Subscribed (mid: 1): 0
sys_interval配置文件中的 1,但我没有收到上述订阅的任何更新。我也尝试订阅一些替代主题,但仍然没有收到任何消息。 Mosquitto 服务器托管在具有 linux 操作系统的 AWS 微型实例上。

最佳答案

$SYS正在被您的 shell 解释为环境变量,并在蚊子看到它之前被替换。您可以通过它在 SUBSCRIBE 日志语句中报告的主题字符串看到这种情况。

您应该在主题字符串周围加上引号:

 $ mosquitto_sub -d -t '$SYS/broker/clients/active'

关于publish-subscribe - Mosquitto 未在 SYS 主题上发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31554113/

相关文章:

c# - 如何创建只有我可以使用 WCF 访问的公共(public)端点和本地端点?

node.js - 使用 aws iot 从 aws lambda 向主题发布 mqtt 消息

ssl - 是否可以通过 mqtt 通信仅进行一次 3way 握手?

linux - mosquitto_sub 错误 :A TLS error occurred but is ok whit --insecure

asp.net - 如何在 Web 应用程序中使用 ServiceStack Redis 以利用发布/订阅范例

azure - Redis 与服务总线的发布/订阅场景

python - 如何在 python 中实现 pub/sub socket.io 客户端?

azure - 无法读取 Azure IoT 中心 MQTT 订阅消息数据

azure - 未从 Azure IoT MQTT 代理接收订阅主题的消息

mqtt - mosquitto 中的最大飞行消息数