¤
amqtt_pub¤
Command-line MQTT client for publishing simple messages.
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, --config-file TEXT |
Client configuration file | No | - |
-i, --client-id TEXT |
client identification for mqtt connection. default: process id and the hostname of the client | No | - |
-q, --qos INTEGER |
Quality of service (0, 1, or 2) [default: 0] | No | - |
-r |
Set retain flag on connect | No | - |
-t, --topic TEXT |
Message topic | Yes | - |
-m, --message TEXT |
Message data to send | No | - |
-f, --file TEXT |
Path to file, will publish each line as a separate message. | No | - |
-s, --stdin |
Read from standard input, all content read is sent as a single message. | No | - |
-l, --lines |
Read from stdin, will publish message for each line. | No | - |
-n, --no-message |
Publish an empty (null, zero length) message | No | - |
-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¤
Publish temperature information to localhost with QoS 1:
amqtt_pub --url mqtt://localhost -t sensors/temperature -m 32 -q 1
Publish timestamp and temperature information to a remote host on a non-standard port and QoS 0:
amqtt_pub --url mqtt://192.168.1.1:1885 -t sensors/temperature -m "1266193804 32"
Publish light switch status. Message is set to retained because there may be a long period of time between light switch events:
amqtt_pub --url mqtt://localhost -r -t switches/kitchen_lights/status -m "on"
Send the contents of a file in two ways:
amqtt_pub --url mqtt://localhost -t my/topic -f ./data
amqtt_pub --url mqtt://localhost -t my/topic -s < ./data
Publish temperature information to localhost with QoS 1 over mqtt encapsulated in a websocket connection and additional headers:
amqtt_pub --url wss://localhost -t sensors/temperature -m 32 -q 1 --extra-headers '{"Authorization": "Bearer <token>"}'