2015-07-22 85 views
3

我正在使用mosquitto服務器作爲mqtt broker。我測試mosquitto的性能,我需要訂閱$ SYS層次結構的一些數據,如目前連接的數量從$SYS/broker/clients/active主題。我有以下蚊子配置文件。Mosquitto未在SYS主題上發佈

# 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話題這樣

[email protected]:/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微型實例上。

回答

8

$SYS被你的shell解釋爲一個環境變量,並在mosquito_sub看到它之前被替換。您可以看到這是由它在SUBSCRIBE日誌語句中報告的主題字符串發生的。

你應該把引號主題字符串:

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

是,它現在的工作。 –