Skip to content

¤

amqtt_sub¤

Command line MQTT client to subscribe to one or more topics and display any messages received.

Usage¤

amqtt_sub [OPTIONS]

Arguments¤

No arguments available

Options¤

Name Description Required Default
--url Broker connection URL, must conform to MQTT or URI scheme: [mqtt(s)|ws(s)]://@HOST:port No -
-c Client configuration file No -
-i, --client-id client identification for mqtt connection. default: process id and the hostname of the client No -
-n Number of messages to read before ending default: read indefinitely No -
-q, --qos Quality of service (0, 1, or 2) No 0
-t Topic filter to subscribe, can be used multiple times. Yes -
-k Keep alive timeout in seconds No -
--clean-session Clean session on connect. default: False No -
--ca-file Define the path to a file containing PEM encoded CA certificates that are trusted. Used to enable SSL communication. No -
--ca-path Define the path to a directory containing PEM encoded CA certificates that are trusted. Used to enable SSL communication. No -
--ca-data Set the PEM encoded CA certificates that are trusted. Used to enable SSL communication. No -
--will-topic The topic on which to send a Will, in the event that the client disconnects unexpectedly. No -
--will-message Specify a message that will be stored by the broker and sent out if this client disconnects unexpectedly. required if --will-topic is specified. No -
--will-qos The QoS to use for the Will. default: 0, only valid if --will-topic is specified No 0
--will-retain If the client disconnects unexpectedly the message sent out will be treated as a retained message. only valid, if --will-topic is specified No -
--extra-headers Specify a JSON object string with key-value pairs representing additional headers that are transmitted on the initial connection. websocket connections only. No -
-d Enable debug messages No -
--version Show version and exit No -
--help Show this message and exit. No -

Commands¤

No commands available

Default Configuration¤

Without the -c argument, the client will run with the following, default configuration:

---
keep_alive: 10
ping_delay: 1
default_qos: 0
default_retain: false
auto_reconnect: true
cleansession: true
reconnect_max_interval: 10
reconnect_retries: 2
connection:
  uri: "mqtt://127.0.0.1"
plugins:
  amqtt.plugins.logging_amqtt.PacketLoggerPlugin:

Using the -c argument allows for configuration with a YAML structured file; see client configuration.

Examples¤

Subscribe with QoS 0 to all messages published under $SYS/:

amqtt_sub --url mqtt://localhost -t '$SYS/#' -q 0

Subscribe to 10 messages with QoS 2 from /#:

amqtt_sub --url mqtt://localhost -t # -q 2 -n 10

Subscribe with QoS 0 to all messages published under $SYS/ over mqtt encapsulated in a websocket connection and additional headers:

amqtt_sub --url wss://localhost -t '$SYS/#' -q 0 --extra-headers '{"Authorization": "Bearer <token>"}'