1MOSQUITTO_SUB(1)                   Commands                   MOSQUITTO_SUB(1)
2
3
4

NAME

6       mosquitto_sub - an MQTT version 5/3.1.1/3.1 client for subscribing to
7       topics
8

SYNOPSIS

10       mosquitto_sub
11                     {[-h hostname] [--unix socket path] [-p port-number] [-u username] [-P password] -t message-topic...
12                     | -L URL [-t message-topic...] } [-A bind-address] [-c]
13                     [-C msg-count] [-d] [-D command identifier value] [-E]
14                     [-i client-id] [-I client-id-prefix] [-k keepalive-time]
15                     [-N] [--nodelay] [--pretty] [-q message-QoS]
16                     [--random-filter chance] [--remove-retained] [-R |
17                     --retained-only] [--retain-as-published] [-S]
18                     [-T filter-out...] [-U unsub-topic...] [-v]
19                     [-V protocol-version] [-W message-processing-timeout]
20                     [-x session-expiry-interval] [--proxy socks-url]
21                     [--quiet]
22                     [--will-topic topic [--will-payload payload] [--will-qos qos] [--will-retain]]
23                     [[{--cafile file | --capath dir} [--cert file] [--key file] [--tls-version version] [--tls-alpn protocol] [--tls-engine engine] [--keyform {pem | engine}] [--tls-engine-kpass-sha1 kpass-sha1] [--tls-use-os-certs] [--insecure]]
24                     |
25                     [--psk hex-key --psk-identity identity [--tls-version version]]]
26
27       mosquitto_sub [--help]
28

DESCRIPTION

30       mosquitto_sub is a simple MQTT version 5/3.1.1 client that will
31       subscribe to topics and print the messages that it receives.
32
33       In addition to subscribing to topics, mosquitto_sub can filter out
34       received messages so they are not printed (see the -T option) or
35       unsubscribe from topics (see the -U option). Unsubscribing from topics
36       is useful for clients connecting with clean session set to false.
37

ENCRYPTED CONNECTIONS

39       mosquitto_sub supports TLS encrypted connections. It is strongly
40       recommended that you use an encrypted connection for anything more than
41       the most basic setup.
42
43       To enable TLS connections when using x509 certificates, one of either
44       --cafile or --capath must be provided as an option.
45
46       To enable TLS connections when using TLS-PSK, you must use the --psk
47       and the --psk-identity options.
48

OPTIONS

50       The options below may be given on the command line, but may also be
51       placed in a config file located at $XDG_CONFIG_HOME/mosquitto_sub or
52       $HOME/.config/mosquitto_sub with one pair of -option value per line.
53       The values in the config file will be used as defaults and can be
54       overridden by using the command line. The exceptions to this are -t and
55       -T, which if given in the config file will not be overridden. Note also
56       that currently some options cannot be negated, e.g.  -S. Config file
57       lines that have a # as the first character are treated as comments and
58       not processed any further.
59
60       -A
61           Bind the outgoing connection to a local ip address/hostname. Use
62           this argument if you need to restrict network communication to a
63           particular interface.
64
65       -c, --disable-clean-session
66           Disable 'clean session' / enable persistent client mode. When this
67           argument is used, the broker will be instructed not to clean
68           existing sessions for the same client id when the client connects,
69           and sessions will never expire when the client disconnects. MQTT v5
70           clients can change their session expiry interval with the -x
71           argument.
72
73           When a session is persisted on the broker, the subscriptions for
74           the client will be maintained after it disconnects, along with
75           subsequent QoS 1 and QoS 2 messages that arrive. When the client
76           reconnects and does not clean the session, it will receive all of
77           the queued messages.
78
79           If using this option, the client id must be set manually with --id
80
81       --cafile
82           Define the path to a file containing PEM encoded CA certificates
83           that are trusted. Used to enable SSL communication.
84
85           See also --capath
86
87       --capath
88           Define the path to a directory containing PEM encoded CA
89           certificates that are trusted. Used to enable SSL communication.
90
91           For --capath to work correctly, the certificate files must have
92           ".crt" as the file ending and you must run "openssl rehash <path to
93           capath>" each time you add/remove a certificate.
94
95           See also --cafile
96
97       --cert
98           Define the path to a file containing a PEM encoded certificate for
99           this client, if required by the server.
100
101           See also --key.
102
103       --ciphers
104           An openssl compatible list of TLS ciphers to support in the client.
105           See ciphers(1) for more information.
106
107       -C
108           Disconnect and exit the program immediately after the given count
109           of messages have been received. This may be useful in shell scripts
110           where on a single status value is required, for example.
111
112           Combine with -R to print only the first set of fresh messages (i.e.
113           that does not have the retained flag set), or with -T to filter
114           which topics are processed.
115
116       -d, --debug
117           Enable debug messages.
118
119       -D, --property
120           Use an MQTT v5 property with this publish. If you use this option,
121           the client will be set to be an MQTT v5 client. This option has two
122           forms:
123
124           -D command identifier value
125
126           -D command identifier name value
127
128           command is the MQTT command/packet identifier and can be one of
129           CONNECT, PUBACK, PUBREC, PUBCOMP, SUBSCRIBE, UNSUBSCRIBE,
130           DISCONNECT, AUTH, or WILL. The properties available for each
131           command are listed in the Properties section.
132
133           identifier is the name of the property to add. This is as described
134           in the specification, but with '-' as a word separator. For
135           example: payload-format-indicator. More details are in the
136           Properties section.
137
138           value is the value of the property to add, with a data type that is
139           property specific.
140
141           name is only used for the user-property property as the first of
142           the two strings in the string pair. In that case, value is the
143           second of the strings in the pair.
144
145       -E
146           If this option is given, mosquitto_sub will exit immediately that
147           all of its subscriptions have been acknowledged by the broker. In
148           conjunction with -c this allows a durable client session to be
149           initialised on the broker for future use without requiring any
150           messages to be received.
151
152       -F
153           Specify output printing format. This option allows you to choose
154           what information from each message is printed to the screen. See
155           the Output Format section below for full details.
156
157           This option overrides the -v option, but does not override the -N
158           option.
159
160       --help
161           Display usage information.
162
163       -h, --host
164           Specify the host to connect to. Defaults to localhost.
165
166       -i, --id
167           The id to use for this client. If not given, a client id will be
168           generated depending on the MQTT version being used. For
169           v3.1.1/v3.1, the client generates a client id in the format
170           mosq-XXXXXXXXXXXXXXXXXX, where the X are replaced with random
171           alphanumeric characters. For v5.0, the client sends a zero length
172           client id, and the server will generate a client id for the client.
173
174           This option cannot be used at the same time as the --id-prefix
175           argument.
176
177       -I, --id-prefix
178           Provide a prefix that the client id will be built from by appending
179           the process id of the client. This is useful where the broker is
180           using the clientid_prefixes option. Cannot be used at the same time
181           as the --id argument.
182
183       --insecure
184           When using certificate based encryption, this option disables
185           verification of the server hostname in the server certificate. This
186           can be useful when testing initial server configurations but makes
187           it possible for a malicious third party to impersonate your server
188           through DNS spoofing, for example. Use this option in testing only.
189           If you need to resort to using this option in a production
190           environment, your setup is at fault and there is no point using
191           encryption.
192
193       -k, --keepalive
194           The number of seconds between sending PING commands to the broker
195           for the purposes of informing it we are still connected and
196           functioning. Defaults to 60 seconds.
197
198       --key
199           Define the path to a file containing a PEM encoded private key for
200           this client, if required by the server.
201
202           See also --cert.
203
204       --keyform
205           Specifies the type of private key in use when making TLS
206           connections.. This can be "pem" or "engine". This parameter is
207           useful when a TPM module is being used and the private key has been
208           created with it. Defaults to "pem", which means normal private key
209           files are used.
210
211           See also --tls-engine.
212
213       -L, --url
214           Specify specify user, password, hostname, port and topic at once as
215           a URL. The URL must be in the form:
216           mqtt(s)://[username[:password]@]host[:port]/topic
217
218           If the scheme is mqtt:// then the port defaults to 1883. If the
219           scheme is mqtts:// then the port defaults to 8883.
220
221       -N
222           Do not append an end of line character to the payload when
223           printing. This allows streaming of payload data from multiple
224           messages directly to another application unmodified. Only really
225           makes sense when not using -v.
226
227       --nodelay
228           Disable Nagle's algorithm for the socket. This means that latency
229           of sent messages is reduced, which is particularly noticable for
230           small, reasonably infrequent messages. Using this option may result
231           in more packets being sent than would normally be necessary.
232
233       -p, --port
234           Connect to the port specified. If not given, the default of 1883
235           for plain MQTT or 8883 for MQTT over TLS will be used.
236
237       -P, --pw
238           Provide a password to be used for authenticating with the broker.
239           Using this argument without also specifying a username is invalid
240           when using MQTT v3.1 or v3.1.1. See also the --username option.
241
242       --pretty
243           When using the JSON output format %j or %J, the default is to print
244           in an unformatted fashion. Specifying --pretty prints messages in a
245           prettier, more human readable format.
246
247       --proxy
248           Specify a SOCKS5 proxy to connect through. "None" and "username"
249           authentication types are supported. The socks-url must be of the
250           form socks5h://[username[:password]@]host[:port]. The protocol
251           prefix socks5h means that hostnames are resolved by the proxy. The
252           symbols %25, %3A and %40 are URL decoded into %, : and @
253           respectively, if present in the username or password.
254
255           If username is not given, then no authentication is attempted. If
256           the port is not given, then the default of 1080 is used.
257
258           More SOCKS versions may be available in the future, depending on
259           demand, and will use different protocol prefixes as described in
260           curl(1).
261
262       --psk
263           Provide the hexadecimal (no leading 0x) pre-shared-key matching the
264           one used on the broker to use TLS-PSK encryption support.
265           --psk-identity must also be provided to enable TLS-PSK.
266
267       --psk-identity
268           The client identity to use with TLS-PSK support. This may be used
269           instead of a username if the broker is configured to do so.
270
271       -q, --qos
272           Specify the quality of service desired for the incoming messages,
273           from 0, 1 and 2. Defaults to 0. See mqtt(7) for more information on
274           QoS.
275
276           The QoS is identical for all topics subscribed to in a single
277           instance of mosquitto_sub.
278
279       --quiet
280           If this argument is given, no runtime errors will be printed. This
281           excludes any error messages given in case of invalid user input
282           (e.g. using --port without a port).
283
284       -R
285           If this argument is given, messages that are received that have the
286           retain bit set will not be printed. Messages with retain set are
287           "stale", in that it is not known when they were originally
288           published. When subscribing to a wildcard topic there may be a
289           large number of retained messages. This argument suppresses their
290           display.
291
292       --random-filter
293           This option can be used to reduce the proportion of messages that
294           mosquitto_sub prints. The default behaviour is to print all
295           incoming messages. Setting the chance to a floating point value
296           between 0.1 and 100.0 will ensure that on average that percentage
297           of messages will be printed.
298
299       --remove-retained
300           If this argument is given, the when mosquitto_sub receives a
301           message with the retained bit set, it will send a message to the
302           broker to clear that retained message. This applies to all received
303           messages except those that are filtered out by the -T option. This
304           option still takes effect even if -R is used. See also the
305           --retain-as-published and --retained-only options.
306
307           Example 1.  Remove all retained messages on the server, assuming we
308           have access to do so, and then exit:
309
310               mosquitto_sub -t '#' --remove-retained --retained-only
311
312           Example 2.  Remove a whole tree, with the exception of a single
313           topic:
314
315               mosquitto_sub -t 'bbc/#' -T bbc/bbc1 --remove-retained
316
317       --retained-only
318           If this argument is given, only messages that are received that
319           have the retain bit set will be printed. Messages with retain set
320           are "stale", in that it is not known when they were originally
321           published. With this argument in use, the receipt of the first
322           non-stale message will cause the client to exit. See also the
323           --retain-as-published option.
324
325       --retain-as-published
326           If this argument is given, the subscriptions will have the "retain
327           as published" option set. This means that the retain flag on an
328           incoming message will be exactly as set by the publishing client,
329           rather than indicating whether the message is fresh/stale.
330
331           This option is not valid for MQTT v3.1/v3.1.1 clients.
332
333       -S
334           Use SRV lookups to determine which host to connect to. Performs
335           lookups to _mqtt._tcp.<host> when used in conjunction with -h,
336           otherwise uses _mqtt._tcp.<local dns domain>.
337
338       -t, --topic
339           The MQTT topic to subscribe to. See mqtt(7) for more information on
340           MQTT topics.
341
342           This option may be repeated to subscribe to multiple topics.
343
344       -T, --filter-out
345           Suppress printing of topics that match the filter. This allows
346           subscribing to a wildcard topic and only printing a partial set of
347           the wildcard hierarchy.
348
349           For example, subscribe to the BBC tree, but suppress output from
350           Radio 3:
351
352           •   mosquitto_sub -t bbc/# -T bbc/radio3
353
354           This option may be repeated to filter out multiple topics or topic
355           trees.
356
357       --tls-alpn
358           Provide a protocol to use when connecting to a broker that has
359           multiple protocols available on a single port, e.g. MQTT and
360           WebSockets.
361
362       --tls-engine
363           A valid openssl engine id. These can be listed with openssl engine
364           command.
365
366           See also --keyform.
367
368       --tls-engine-kpass-sha1
369           SHA1 of the private key password when using an TLS engine. Some TLS
370           engines such as the TPM engine may require the use of a password in
371           order to be accessed. This option allows a hex encoded SHA1 hash of
372           the password to the engine directly, instead of the user being
373           prompted for the password.
374
375           See also --tls-engine.
376
377       --tls-use-os-certs
378           If used, this will load and trust the OS provided CA certificates.
379           This can be used in conjunction with --cafile and --capath and can
380           be used on its own to enable TLS mode. This will be set by default
381           if -L mqtts://...  is used, or if port is 8883 and no other
382           certificate options are used.
383
384       --tls-version
385           Choose which TLS protocol version to use when communicating with
386           the broker. Valid options are tlsv1.3, tlsv1.2 and tlsv1.1. The
387           default value is tlsv1.2. Must match the protocol version used by
388           the broker.
389
390       -u, --username
391           Provide a username to be used for authenticating with the broker.
392           See also the --pw argument.
393
394       --unix
395           Connect to a broker through a local unix domain socket instead of a
396           TCP socket. This is a replacement for -h and -L. For example:
397           mosquitto_pub --unix /tmp/mosquitto.sock ...
398
399           See the socket_domain option in mosquitto.conf(5) to configure
400           Mosquitto to listen on a unix socket.
401
402       -U, --unsubscribe
403           A topic that will be unsubscribed from. This may be used on its own
404           or in conjunction with the --topic option and only makes sense when
405           used in conjunction with --clean-session.
406
407           If used with --topic then subscriptions will be processed before
408           unsubscriptions.
409
410           Note that it is only possible to unsubscribe from subscriptions
411           that have previously been made. It is not possible to punch holes
412           in wildcard subscriptions. For example, subscribing to sensors/#
413           and then unsubscribing from sensors/+/temperature as shown below
414           will still result in messages matching the sensors/+/temperature
415           being delivered to the client.
416
417           •   mosquitto_sub -t sensors/# -U sensors/+/temperature -v
418
419           Note also that because retained messages are published by the
420           broker on receipt of a SUBSCRIBE command, subscribing and
421           unsubscribing to the same topic may result in messages being
422           received at the client.
423
424           This option may be repeated to unsubscribe from multiple topics.
425
426       -v, --verbose
427           Print received messages verbosely. With this argument, messages
428           will be printed as "topic payload". When this argument is not
429           given, the messages are printed as "payload".
430
431       -V, --protocol-version
432           Specify which version of the MQTT protocol should be used when
433           connecting to the remote broker. Can be 5, 311, 31, or the more
434           verbose mqttv5, mqttv311, or mqttv31. Defaults to 311.
435
436       -W
437           Provide a timeout as an integer number of seconds. mosquitto_sub
438           will stop processing messages and disconnect after this number of
439           seconds has passed. The timeout starts just after the client has
440           connected to the broker.
441
442       --will-payload
443           Specify a message that will be stored by the broker and sent out if
444           this client disconnects unexpectedly. This must be used in
445           conjunction with --will-topic.
446
447       --will-qos
448           The QoS to use for the Will. Defaults to 0. This must be used in
449           conjunction with --will-topic.
450
451       --will-retain
452           If given, if the client disconnects unexpectedly the message sent
453           out will be treated as a retained message. This must be used in
454           conjunction with --will-topic.
455
456       --will-topic
457           The topic on which to send a Will, in the event that the client
458           disconnects unexpectedly.
459
460       -x
461           Set the session-expiry-interval property on the CONNECT packet.
462           Applies to MQTT v5 clients only. Set to 0-4294967294 to specify the
463           session will expire in that many seconds after the client
464           disconnects, or use -1, 4294967295, or ∞ for a session that does
465           not expire. Defaults to -1 if -c is also given, or 0 if -c not
466           given.
467
468           If the session is set to never expire, either with -x or -c, then a
469           client id must be provided.
470

OUTPUT FORMAT

472       There are three ways of formatting the output from mosquitto_sub. In
473       all cases a new-line character is appended for each message received
474       unless the -N argument is passed to mosquitto_sub.
475
476       Payload-only is the default output format and will print the payload
477       exactly as it is received.
478
479       Verbose mode is activated with -v and prints the message topic and the
480       payload, separated by a space.
481
482       The final option is formatted output, which allows the user to define a
483       custom output format. The behaviour is controlled with the -F
484       format-string option. The format string is a free text string where
485       interpreted sequences are replaced by different parameters. The
486       available interpreted sequences are described below.
487
488       Three characters are used to start an interpreted sequence: %, @ and \.
489       Sequences starting with % are either parameters related to the MQTT
490       message being printed, or are helper sequences to avoid the need to
491       type long date format strings for example. Sequences starting with @
492       are passed to the strftime(3) function (with the @ replaced with a % -
493       note that only the character immediately after the @ is passed to
494       strftime). This allows the construction of a wide variety of time based
495       outputs. The output options for strftime vary from platform to
496       platform, so please check what is available for your platform.
497       mosquitto_sub does provide one extension to strftime which is @N, which
498       can be used to obtain the number of nanoseconds passed in the current
499       second. The resolution of this option varies depending on the platform.
500       The final sequence character is \, which is used to input some
501       characters that would otherwise be difficult to enter.
502
503   Flag characters
504       The parameters %A, %C, %E, %F, %I, %l, %m, %p, %R, %S, %t, %x, and %X
505       can have optional flags immediately after the % character.
506
507       0
508           The value should be zero padded. This applies to the parameters %A,
509           %E, %F, %l, %m, %S, %X, and %x. It will be ignored for other
510           parameters. If used with the - flag, the 0 flag will be ignored.
511
512       -
513           The value will be left aligned to the field width, padded with
514           blanks. The default is right alignment, with either 0 or blank
515           padding.
516
517   Field width
518       Some of the MQTT related parameters can be formatted with an option to
519       set their field width in a similar way to regular printf style formats,
520       i.e. this sets the minimum width when printing this parameter. This
521       applies to the options %A, %C, %E, %F, %I, %l, %m, %p, %R, %S, %t, %x,
522       %X.
523
524       For example %10t would set the minimum topic field width to 10
525       characters.
526
527   Maximum width
528       Some of the MQTT related parameters can be formatted with an option to
529       set a maximum field width in a similar way to regular printf style
530       formats. This applies to the options %C, %I, %R, %t.
531
532       For example %10.10t would set the minimum topic field width to 10
533       characters, and the maximum topic width to 10 characters, i.e. the
534       field will always be exactly 10 characters long.
535
536   MQTT related parameters
537%% a literal %.
538
539%A the MQTT v5 topic-alias property, if present.
540
541%C the MQTT v5 content-type property, if present.
542
543%D the MQTT v5 correlation-data property, if present. Note that
544           this property is specified as binary data, so may produce
545           non-printable characters.
546
547%E the MQTT v5 message-expiry-interval property, if present.
548
549%F the MQTT v5 payload-format-indicator property, if present.
550
551%l the length of the payload in bytes.
552
553%m the message id (only relevant for messages with QoS>0).
554
555%P the MQTT v5 user-property property, if present. This will be
556           printed in the form key:value. It is possible for any number of
557           user properties to be attached to a message, and to have duplicate
558           keys.
559
560%p the payload raw bytes (may produce non-printable characters
561           depending on the payload).
562
563%q the message QoS.
564
565%R the MQTT v5 response-topic property, if present.
566
567%r the retained flag for the message.
568
569%S the MQTT v5 subscription-identifier property, if present.
570
571%t the message topic.
572
573%x the payload with each byte as a hexadecimal number (lower case).
574
575%X the payload with each byte as a hexadecimal number (upper case).
576
577   Helpers
578%I ISO-8601 format date and time, e.g. 2016-08-10T09:47:38+0100
579
580%j JSON output of message parameters and timestamp, with a quoted
581           and escaped payload. For example
582           {"tst":"2020-05-06T22:12:00.000000+0100","topic":"greeting","qos":0,"retain":0,"payload":"hello
583           world"}
584
585%J JSON output of message parameters and timestamp, with a
586           non-quoted and non-escaped payload - this means the payload must
587           itself be valid JSON. For example:
588           {"tst":"2020-05-06T22:12:00.000000+0100","topic":"foo","qos":0,"retain":0,"payload":{"temperature":27.0,"humidity":57}}.
589
590           If the payload is not valid JSON, then the error message "Error:
591           Message payload is not valid JSON on topic <topic>" will be printed
592           to stderr.
593
594%I ISO-8601 format date and time, e.g. 2016-08-10T09:47:38+0100
595
596%U Unix timestamp with nanoseconds, e.g. 1470818943.786368637
597
598   Time related parameters
599@@ a literal @.
600
601@X pass the character represented by X to the strftime function as
602           %X. The options supported are platform dependent.
603
604@N the number of nanoseconds that have passed in the current
605           second, with varying timing resolution depending on platform.
606
607   Escape characters
608\\ a literal \.
609
610\0 a null character. Can be used to separate different parameters
611           that may contain spaces (e.g. topic, payload) so that processing
612           with tools such as xargs(1) is easier.
613
614\a alert/bell.
615
616\e the escape sequence, which can be used with ANSI colour codes to
617           provide coloured output for example.
618
619\n end of line.
620
621\r carriage return.
622
623\t horizontal tab.
624
625\v vertical tab.
626

WILLS

628       mosquitto_sub can register a message with the broker that will be sent
629       out if it disconnects unexpectedly. See mqtt(7) for more information.
630
631       The minimum requirement for this is to use --will-topic to specify
632       which topic the will should be sent out on. This will result in a
633       non-retained, zero length message with QoS 0.
634
635       Use the --will-retain, --will-payload and --will-qos arguments to
636       modify the other will parameters.
637

PROPERTIES

639       The -D / --property option allows adding properties to different stages
640       of the mosquitto_sub run. The properties supported for each command are
641       as follows:
642
643   Connect
644authentication-data (binary data - note treated as a string in
645           mosquitto_sub)
646
647authentication-method (UTF-8 string)
648
649maximum-packet-size (32-bit unsigned integer)
650
651receive-maximum (16-bit unsigned integer)
652
653request-problem-information (8-bit unsigned integer)
654
655request-response-information (8-bit unsigned integer)
656
657session-expiry-interval (32-bit unsigned integer, note use -x
658           instead)
659
660topic-alias-maximum (16-bit unsigned integer)
661
662user-property (UTF-8 string pair)
663
664   Subscribe
665user-property (UTF-8 string pair)
666
667   Unsubscribe
668user-property (UTF-8 string pair)
669
670   Disconnect
671session-expiry-interval (32-bit unsigned integer)
672
673user-property (UTF-8 string pair)
674
675   Will properties
676content-type (UTF-8 string)
677
678correlation-data (binary data - note treated as a string in
679           mosquitto_sub)
680
681message-expiry-interval (32-bit unsigned integer)
682
683payload-format-indicator (8-bit unsigned integer)
684
685response-topic (UTF-8 string)
686
687user-property (UTF-8 string pair)
688
689will-delay-interval (32-bit unsigned integer)
690

EXIT STATUS

692       mosquitto_sub returns zero on success, or non-zero on error. If the
693       connection is refused by the broker at the MQTT level, then the exit
694       code is the CONNACK reason code. If another error occurs, the exit code
695       is a libmosquitto return value.
696
697       MQTT v3.1.1 CONNACK codes:
698
6990 Success
700
7011 Connection refused: Bad protocol version
702
7032 Connection refused: Identifier rejected
704
7053 Connection refused: Server unavailable
706
7074 Connection refused: Bad username/password
708
7095 Connection refused: Not authorized
710
711       MQTT v5 CONNACK codes:
712
7130 Success
714
715128 Unspecified error
716
717129 Malformed packet
718
719130 Protocol error
720
721131 Implementation specific error
722
723132 Unsupported protocol version
724
725133 Client ID not valid
726
727134 Bad username or password
728
729135 Not authorized
730
731136 Server unavailable
732
733137 Server busy
734
735138 Banned
736
737139 Server shutting down
738
739140 Bad authentication method
740
741141 Keep alive timeout
742
743142 Session taken over
744
745143 Topic filter invalid
746
747144 Topic name invalid
748
749147 Receive maximum exceeded
750
751148 Topic alias invalid
752
753149 Packet too large
754
755148 Message rate too high
756
757151 Quota exceeded
758
759152 Administrative action
760
761153 Payload format invalid
762
763154 Retain not supported
764
765155 QoS not supported
766
767156 Use another server
768
769157 Server moved
770
771158 Shared subscriptions not supported
772
773159 Connection rate exceeded
774
775160 Maximum connect time
776
777161 Subscription IDs not supported
778
779162 Wildcard subscriptions not supported
780

EXAMPLES

782       Note that these really are examples - the subscriptions will work if
783       you run them as shown, but there must be something publishing messages
784       on those topics for you to receive anything.
785
786       Subscribe to temperature information on localhost with QoS 1:
787
788       •   mosquitto_sub -t sensors/temperature -q 1
789
790       Subscribe to hard drive temperature updates on multiple machines/hard
791       drives. This expects each machine to be publishing its hard drive
792       temperature to sensors/machines/HOSTNAME/temperature/HD_NAME.
793
794       •   mosquitto_sub -t sensors/machines/+/temperature/+
795
796       Subscribe to all broker status messages:
797
798       •   mosquitto_sub -v -t \$SYS/#
799
800       Specify the output format as "ISO-8601 date : topic : payload in hex"
801
802       •   mosquitto_sub -F '@Y-@m-@dT@H:@M:@S@z : %t : %x' -t '#'
803
804       Specify the output format as "seconds since epoch.nanoseconds :
805       retained flag : qos : mid : payload length"
806
807       •   mosquitto_sub -F '%@s.@N : %r : %q : %m : %l' -q 2 -t '#'
808
809       Topic and payload output, but with colour where supported.
810
811       •   mosquitto_sub -F '\e[92m%t \e[96m%p\e[0m' -q 2 -t '#'
812

EXIT VALUES

814       0
815           Success
816
817       27
818           Timed out waiting for message
819
820       Other non-zero value
821           Unspecified failure
822

FILES

824       $XDG_CONFIG_HOME/mosquitto_sub, $HOME/.config/mosquitto_sub
825           Configuration file for default options.
826

BUGS

828       mosquitto bug information can be found at
829       https://github.com/eclipse/mosquitto/issues
830

SEE ALSO

832       mqtt(7), mosquitto_pub(1), mosquitto_rr(1), mosquitto(8),
833       libmosquitto(3), mosquitto-tls(7)
834

AUTHOR

836       Roger Light <roger@atchoo.org>
837
838
839
840Mosquitto Project                 04/03/2021                  MOSQUITTO_SUB(1)
Impressum