mosquitto_pub
publishes messages to an MQTT broker
TLDR
Publish message to topic
$ mosquitto_pub -t [topic] -m "[message]"
Publish to remote broker$ mosquitto_pub -h [broker.example.com] -t [topic] -m "[message]"
Publish with authentication$ mosquitto_pub -h [host] -u [user] -P [password] -t [topic] -m "[message]"
Publish file contents$ mosquitto_pub -t [topic] -f [file.txt]
Publish with QoS$ mosquitto_pub -t [topic] -m "[message]" -q [1]
Publish retained message$ mosquitto_pub -t [topic] -m "[message]" -r
SYNOPSIS
mosquitto_pub [options]
DESCRIPTION
mosquitto_pub publishes messages to an MQTT broker. It's part of the Mosquitto package.
The tool sends single messages. Supports authentication, TLS, and various QoS levels.
PARAMETERS
-h HOST
MQTT broker hostname.-t TOPIC
Topic to publish to.-m MESSAGE
Message payload.-u USER
Username.-P PASSWORD
Password.-q QOS
Quality of service (0, 1, 2).-r
Retain message.--help
Display help information.
CAVEATS
Part of mosquitto-clients. Requires broker access. Default QoS is 0.
HISTORY
mosquitto_pub is the publishing client distributed with the Eclipse Mosquitto MQTT broker.
SEE ALSO
mosquitto_sub(1), mosquitto(1), mqtt(1)
