Skip to content

¤

amqtt_pub¤

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

Usage¤

amqtt_pub [OPTIONS]

Arguments¤

No arguments available

Options¤

Name Description Required Default
--url TEXT Broker connection URL, must conform to MQTT or URI scheme: ://<username:password>@HOST:port No -
-c TEXT Client configuration file No -
-i, --client-id TEXT client identification for mqtt connection. default: process id and the hostname of the client No -
-n INTEGER Number of messages to read before ending default: read indefinitely No -
-q, --qos INTEGER Quality of service (0, 1, or 2) [default: 0] No -
-t TEXT Topic filter to subscribe, can be used multiple times. Yes -
-k INTEGER Keep alive timeout in seconds No -
--clean-session Clean session on connect. default: False No -
--ca-file TEXT Define the path to a file containing PEM encoded CA certificates that are trusted. Used to enable SSL communication. No -
--ca-path TEXT Define the path to a directory containing PEM encoded CA certificates that are trusted. Used to enable SSL communication. No -
--ca-data TEXT Set the PEM encoded CA certificates that are trusted. Used to enable SSL communication. No -
--will-topic TEXT The topic on which to send a Will, in the event that the client disconnects unexpectedly. No -
--will-message TEXT 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 INTEGER The QoS to use for the Will. default: 0, only valid if --will-topic is specified [default: 0] No -
--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 TEXT 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>"}'