Vin*_*mar 6 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
Run Code Online (Sandbox Code Playgroud)
我正在订阅这样的$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
Run Code Online (Sandbox Code Playgroud)
在sys_interval配置文件中为1,但我没有收到以上认购任何更新.我也试过这个订阅一些替代主题,但仍然没有收到任何东西.Mosquitto服务器托管在具有Linux操作系统的AWS微实例上.
kno*_*ary 17
$SYS正被shell解释为环境变量,并在mosquito_sub看到之前被替换.您可以通过它在SUBSCRIBE日志语句中报告的主题字符串看到这种情况.
你应该在主题字符串周围加上引号:
$ mosquitto_sub -d -t '$SYS/broker/clients/active'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3881 次 |
| 最近记录: |