'\" -*- coding: us-ascii -*- .if \n(.g .ds T< \\FC .if \n(.g .ds T> \\F[\n[.fam]] .de URL \\$2 \(la\\$1\(ra\\$3 .. .if \n(.g .mso www.tmac .TH mosquitto_sub 1 "5 February 2012" "" "" .SH NAME mosquitto_sub \- an mqtt version 3.1 client for subscribing to topics .SH SYNOPSIS 'nh .fi .ad l \fBmosquitto_sub\fR \kx .if (\nx>(\n(.l/2)) .nr x (\n(.l/5) 'in \n(.iu+\nxu [\fB-c\fR] [\fB-d\fR] [\fB-h\fR \fIhostname\fR] [\fB-i\fR \fIclient_id\fR] [\fB-I\fR \fIclient id prefix\fR] [\fB-k\fR \fIkeepalive time\fR] [\fB-p\fR \fIport number\fR] [\fB-q\fR \fImessage QoS\fR] [\fB--quiet\fR] [\fB-v\fR] [ \fB-u\fR \fIusername\fR [\fB-P\fR \fIpassword\fR] ] [ \fB--will-topic\fR \fItopic\fR [\fB--will-payload\fR \fIpayload\fR] [\fB--will-qos\fR \fIqos\fR] [\fB--will-retain\fR] ] \fB-t\fR \fImessage topic\fR \&... 'in \n(.iu-\nxu .ad b 'hy .SH DESCRIPTION \fBmosquitto_sub\fR is a simple mqtt version 3.1 client that will subscribe to a topic and print the messages that it receives. .SH OPTIONS .TP \*(T<\fB\-c\fR\*(T>, \*(T<\fB\-\-disable\-clean\-session\fR\*(T> Disable the 'clean session' flag. This means that all of the subscriptions for the client will be maintained after it disconnects, along with subsequent QoS 1 and QoS 2 messages that arrive. When the client reconnects, it will receive all of the queued messages. If using this option, it is recommended that the client id is set manually with \*(T<\fB\-\-id\fR\*(T> .TP \*(T<\fB\-d\fR\*(T>, \*(T<\fB\-\-debug\fR\*(T> Enable debug messages. .TP \*(T<\fB\-h\fR\*(T>, \*(T<\fB\-\-host\fR\*(T> Specify the host to connect to. Defaults to localhost. .TP \*(T<\fB\-i\fR\*(T>, \*(T<\fB\-\-id\fR\*(T> The id to use for this client. If not given, defaults to mosquitto_sub_ appended with the process id of the client. Cannot be used at the same time as the \*(T<\fB\-\-id\-prefix\fR\*(T> argument. .TP \*(T<\fB\-I\fR\*(T>, \*(T<\fB\-\-id\-prefix\fR\*(T> Provide a prefix that the client id will be built from by appending the process id of the client. This is useful where the broker is using the clientid_prefixes option. Cannot be used at the same time as the \*(T<\fB\-\-id\fR\*(T> argument. .TP \*(T<\fB\-k\fR\*(T>, \*(T<\fB\-\-keepalive\fR\*(T> The number of seconds between sending PING commands to the broker for the purposes of informing it we are still connected and functioning. Defaults to 60 seconds. .TP \*(T<\fB\-p\fR\*(T>, \*(T<\fB\-\-port\fR\*(T> Connect to the port specified instead of the default 1883. .TP \*(T<\fB\-P\fR\*(T>, \*(T<\fB\-\-pw\fR\*(T> Provide a password to be used for authenticating with the broker. Using this argument without also specifying a username is invalid. This requires a broker that supports MQTT v3.1. See also the \*(T<\fB\-\-username\fR\*(T> option. .TP \*(T<\fB\-q\fR\*(T>, \*(T<\fB\-\-qos\fR\*(T> Specify the quality of service desired for the incoming messages, from 0, 1 and 2. Defaults to 0. See \fBmqtt\fR(7) for more information on QoS. The QoS is identical for all topics subscribed to in a single instance of mosquitto_sub. .TP \*(T<\fB\-\-quiet\fR\*(T> If this argument is given, no runtime errors will be printed. This excludes any error messages given in case of invalid user input (e.g. using \*(T<\fB\-\-port\fR\*(T> without a port). .TP \*(T<\fB\-t\fR\*(T>, \*(T<\fB\-\-topic\fR\*(T> The mqtt topic to subscribe to. See \fBmqtt\fR(7) for more information on mqtt topics. This option may be repeated to subscribe to multiple topics. .TP \*(T<\fB\-u\fR\*(T>, \*(T<\fB\-\-username\fR\*(T> Provide a username to be used for authenticating with the broker. This requires a broker that supports MQTT v3.1. See also the \*(T<\fB\-\-pw\fR\*(T> argument. .TP \*(T<\fB\-v\fR\*(T>, \*(T<\fB\-\-verbose\fR\*(T> Print received messages verbosely. With this argument, messages will be printed as "topic payload". When this argument is not given, the messages are printed as "payload". .TP \*(T<\fB\-\-will\-payload\fR\*(T> Specify a message that will be stored by the broker and sent out if this client disconnects unexpectedly. This must be used in conjunction with \*(T<\fB\-\-will\-topic\fR\*(T>. .TP \*(T<\fB\-\-will\-qos\fR\*(T> The QoS to use for the Will. Defaults to 0. This must be used in conjunction with \*(T<\fB\-\-will\-topic\fR\*(T>. .TP \*(T<\fB\-\-will\-retain\fR\*(T> If given, if the client disconnects unexpectedly the message sent out will be treated as a retained message. This must be used in conjunction with \*(T<\fB\-\-will\-topic\fR\*(T>. .TP \*(T<\fB\-\-will\-topic\fR\*(T> The topic on which to send a Will, in the event that the client disconnects unexpectedly. .SH WILLS mosquitto_sub can register a message with the broker that will be sent out if it disconnects unexpectedly. See \fBmqtt\fR(7) for more information. .PP The minimum requirement for this is to use \*(T<\fB\-\-will\-topic\fR\*(T> to specify which topic the will should be sent out on. This will result in a non-retained, zero length message with QoS 0. .PP Use the \*(T<\fB\-\-will\-retain\fR\*(T>, \*(T<\fB\-\-will\-payload\fR\*(T> and \*(T<\fB\-\-will\-qos\fR\*(T> arguments to modify the other will parameters. .SH EXAMPLES Note that these really are examples - the subscriptions will work if you run them as shown, but there must be something publishing messages on those topics for you to receive anything. .PP Subscribe to temperature information on localhost with QoS 1: .TP 0.2i \(bu mosquitto_sub \*(T<\-t\*(T> sensors/temperature \*(T<\-q\*(T> 1 .PP Subscribe to hard drive temperature updates on multiple machines/hard drives. This expects each machine to be publishing its hard drive temperature to sensors/machines/HOSTNAME/temperature/HD_NAME. .TP 0.2i \(bu mosquitto_sub \*(T<\-t\*(T> sensors/machines/+/temperature/+ .PP Subscribe to all broker status messages: .TP 0.2i \(bu mosquitto_sub \*(T<\-v\*(T> \*(T<\-t\*(T> \e$SYS/# .SH BUGS \fBmosquitto_sub\fR bug information can be found at http://launchpad.net/mosquitto .SH "SEE ALSO" \fBmqtt\fR(7) \fBmosquitto_pub\fR(1) \fBmosquitto\fR(8) \fBlibmosquitto\fR(3) .SH AUTHOR Roger Light <\*(T>