Vinod Kumar
Vinod Kumar

Reputation: 489

Mosquitto not publishing on SYS topics

I am using mosquitto server as mqtt broker. I testing mosquitto for performance and I need to subscribe to $SYS hierarchy for some data like number of currently connected from $SYS/broker/clients/active topic. I have following mosquitto config file.

# 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

I am subscribing to $SYS/broker/clients/active topic like this

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

The sys_interval in config file is 1, but I am not receiving any updates on above subscription. I also tried this subscribing to some alternative topics, but still not receiving anything. Mosquitto server is hosted on an AWS micro instance with linux operating system.

Upvotes: 8

Views: 9940

Answers (1)

knolleary
knolleary

Reputation: 10117

$SYS is being interpreted by you shell as an environment variable and is being substituted before mosquito_sub sees it. You can see this has happened by the topic string it reports in the SUBSCRIBE log statement.

You should put quotes around the topic string:

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

Upvotes: 22

Related Questions