1MOSQUITTO_SUB(1) Commands MOSQUITTO_SUB(1)
2
3
4
6 mosquitto_sub - an MQTT version 5/3.1.1/3.1 client for subscribing to
7 topics
8
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
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
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 can be provided as an option.
45
46 Alternatively, if the -p 8883 option is used then the OS provided
47 certificates will be loaded and neither --cafile or --capath are needed
48
49 To enable TLS connections when using TLS-PSK, you must use the --psk
50 and the --psk-identity options.
51
53 The options below may be given on the command line, but may also be
54 placed in a config file located at $XDG_CONFIG_HOME/mosquitto_sub or
55 $HOME/.config/mosquitto_sub with one pair of -option value per line.
56 The values in the config file will be used as defaults and can be
57 overridden by using the command line. The exceptions to this are -t and
58 -T, which if given in the config file will not be overridden. Note also
59 that currently some options cannot be negated, e.g. -S. Config file
60 lines that have a # as the first character are treated as comments and
61 not processed any further.
62
63 -A
64 Bind the outgoing connection to a local ip address/hostname. Use
65 this argument if you need to restrict network communication to a
66 particular interface.
67
68 -c, --disable-clean-session
69 Disable 'clean session' / enable persistent client mode. When this
70 argument is used, the broker will be instructed not to clean
71 existing sessions for the same client id when the client connects,
72 and sessions will never expire when the client disconnects. MQTT v5
73 clients can change their session expiry interval with the -x
74 argument.
75
76 When a session is persisted on the broker, the subscriptions for
77 the client will be maintained after it disconnects, along with
78 subsequent QoS 1 and QoS 2 messages that arrive. When the client
79 reconnects and does not clean the session, it will receive all of
80 the queued messages.
81
82 If using this option, the client id must be set manually with --id
83
84 --cafile
85 Define the path to a file containing PEM encoded CA certificates
86 that are trusted. Used to enable SSL communication.
87
88 See also --capath
89
90 --capath
91 Define the path to a directory containing PEM encoded CA
92 certificates that are trusted. Used to enable SSL communication.
93
94 For --capath to work correctly, the certificate files must have
95 ".crt" as the file ending and you must run "openssl rehash <path to
96 capath>" each time you add/remove a certificate.
97
98 See also --cafile
99
100 --cert
101 Define the path to a file containing a PEM encoded certificate for
102 this client, if required by the server.
103
104 See also --key.
105
106 --ciphers
107 An openssl compatible list of TLS ciphers to support in the client.
108 See ciphers(1) for more information.
109
110 -C
111 Disconnect and exit the program immediately after the given count
112 of messages have been received. This may be useful in shell scripts
113 where on a single status value is required, for example.
114
115 Combine with -R to print only the first set of fresh messages (i.e.
116 that does not have the retained flag set), or with -T to filter
117 which topics are processed.
118
119 -d, --debug
120 Enable debug messages.
121
122 -D, --property
123 Use an MQTT v5 property with this publish. If you use this option,
124 the client will be set to be an MQTT v5 client. This option has two
125 forms:
126
127 -D command identifier value
128
129 -D command identifier name value
130
131 command is the MQTT command/packet identifier and can be one of
132 CONNECT, PUBACK, PUBREC, PUBCOMP, SUBSCRIBE, UNSUBSCRIBE,
133 DISCONNECT, AUTH, or WILL. The properties available for each
134 command are listed in the Properties section.
135
136 identifier is the name of the property to add. This is as described
137 in the specification, but with '-' as a word separator. For
138 example: payload-format-indicator. More details are in the
139 Properties section.
140
141 value is the value of the property to add, with a data type that is
142 property specific.
143
144 name is only used for the user-property property as the first of
145 the two strings in the string pair. In that case, value is the
146 second of the strings in the pair.
147
148 -E
149 If this option is given, mosquitto_sub will exit immediately that
150 all of its subscriptions have been acknowledged by the broker. In
151 conjunction with -c this allows a durable client session to be
152 initialised on the broker for future use without requiring any
153 messages to be received.
154
155 -F
156 Specify output printing format. This option allows you to choose
157 what information from each message is printed to the screen. See
158 the Output Format section below for full details.
159
160 This option overrides the -v option, but does not override the -N
161 option.
162
163 --help
164 Display usage information.
165
166 -h, --host
167 Specify the host to connect to. Defaults to localhost.
168
169 -i, --id
170 The id to use for this client. If not given, a client id will be
171 generated depending on the MQTT version being used. For
172 v3.1.1/v3.1, the client generates a client id in the format
173 mosq-XXXXXXXXXXXXXXXXXX, where the X are replaced with random
174 alphanumeric characters. For v5.0, the client sends a zero length
175 client id, and the server will generate a client id for the client.
176
177 This option cannot be used at the same time as the --id-prefix
178 argument.
179
180 -I, --id-prefix
181 Provide a prefix that the client id will be built from by appending
182 the process id of the client. This is useful where the broker is
183 using the clientid_prefixes option. Cannot be used at the same time
184 as the --id argument.
185
186 --insecure
187 When using certificate based encryption, this option disables
188 verification of the server hostname in the server certificate. This
189 can be useful when testing initial server configurations but makes
190 it possible for a malicious third party to impersonate your server
191 through DNS spoofing, for example. Use this option in testing only.
192 If you need to resort to using this option in a production
193 environment, your setup is at fault and there is no point using
194 encryption.
195
196 -k, --keepalive
197 The number of seconds between sending PING commands to the broker
198 for the purposes of informing it we are still connected and
199 functioning. Defaults to 60 seconds.
200
201 --key
202 Define the path to a file containing a PEM encoded private key for
203 this client, if required by the server.
204
205 See also --cert.
206
207 --keyform
208 Specifies the type of private key in use when making TLS
209 connections.. This can be "pem" or "engine". This parameter is
210 useful when a TPM module is being used and the private key has been
211 created with it. Defaults to "pem", which means normal private key
212 files are used.
213
214 See also --tls-engine.
215
216 -L, --url
217 Specify specify user, password, hostname, port and topic at once as
218 a URL. The URL must be in the form:
219 mqtt(s)://[username[:password]@]host[:port]/topic
220
221 If the scheme is mqtt:// then the port defaults to 1883. If the
222 scheme is mqtts:// then the port defaults to 8883.
223
224 -N
225 Do not append an end of line character to the payload when
226 printing. This allows streaming of payload data from multiple
227 messages directly to another application unmodified. Only really
228 makes sense when not using -v.
229
230 --nodelay
231 Disable Nagle's algorithm for the socket. This means that latency
232 of sent messages is reduced, which is particularly noticeable for
233 small, reasonably infrequent messages. Using this option may result
234 in more packets being sent than would normally be necessary.
235
236 -p, --port
237 Connect to the port specified. If not given, the default of 1883
238 for plain MQTT or 8883 for MQTT over TLS will be used.
239
240 -P, --pw
241 Provide a password to be used for authenticating with the broker.
242 Using this argument without also specifying a username is invalid
243 when using MQTT v3.1 or v3.1.1. See also the --username option.
244
245 --pretty
246 When using the JSON output format %j or %J, the default is to print
247 in an unformatted fashion. Specifying --pretty prints messages in a
248 prettier, more human readable format.
249
250 --proxy
251 Specify a SOCKS5 proxy to connect through. "None" and "username"
252 authentication types are supported. The socks-url must be of the
253 form socks5h://[username[:password]@]host[:port]. The protocol
254 prefix socks5h means that hostnames are resolved by the proxy. The
255 symbols %25, %3A and %40 are URL decoded into %, : and @
256 respectively, if present in the username or password.
257
258 If username is not given, then no authentication is attempted. If
259 the port is not given, then the default of 1080 is used.
260
261 More SOCKS versions may be available in the future, depending on
262 demand, and will use different protocol prefixes as described in
263 curl(1).
264
265 --psk
266 Provide the hexadecimal (no leading 0x) pre-shared-key matching the
267 one used on the broker to use TLS-PSK encryption support.
268 --psk-identity must also be provided to enable TLS-PSK.
269
270 --psk-identity
271 The client identity to use with TLS-PSK support. This may be used
272 instead of a username if the broker is configured to do so.
273
274 -q, --qos
275 Specify the quality of service desired for the incoming messages,
276 from 0, 1 and 2. Defaults to 0. See mqtt(7) for more information on
277 QoS.
278
279 The QoS is identical for all topics subscribed to in a single
280 instance of mosquitto_sub.
281
282 --quiet
283 If this argument is given, no runtime errors will be printed. This
284 excludes any error messages given in case of invalid user input
285 (e.g. using --port without a port).
286
287 -R
288 If this argument is given, messages that are received that have the
289 retain bit set will not be printed. Messages with retain set are
290 "stale", in that it is not known when they were originally
291 published. When subscribing to a wildcard topic there may be a
292 large number of retained messages. This argument suppresses their
293 display.
294
295 --random-filter
296 This option can be used to reduce the proportion of messages that
297 mosquitto_sub prints. The default behaviour is to print all
298 incoming messages. Setting the chance to a floating point value
299 between 0.1 and 100.0 will ensure that on average that percentage
300 of messages will be printed.
301
302 --remove-retained
303 If this argument is given, the when mosquitto_sub receives a
304 message with the retained bit set, it will send a message to the
305 broker to clear that retained message. This applies to all received
306 messages except those that are filtered out by the -T option. This
307 option still takes effect even if -R is used. See also the
308 --retain-as-published and --retained-only options.
309
310 Example 1. Remove all retained messages on the server, assuming we
311 have access to do so, and then exit:
312
313 mosquitto_sub -t '#' --remove-retained --retained-only
314
315 Example 2. Remove a whole tree, with the exception of a single
316 topic:
317
318 mosquitto_sub -t 'bbc/#' -T bbc/bbc1 --remove-retained
319
320 --retained-only
321 If this argument is given, only messages that are received that
322 have the retain bit set will be printed. Messages with retain set
323 are "stale", in that it is not known when they were originally
324 published. With this argument in use, the receipt of the first
325 non-stale message will cause the client to exit. See also the
326 --retain-as-published option.
327
328 --retain-as-published
329 If this argument is given, the subscriptions will have the "retain
330 as published" option set. This means that the retain flag on an
331 incoming message will be exactly as set by the publishing client,
332 rather than indicating whether the message is fresh/stale.
333
334 This option is not valid for MQTT v3.1/v3.1.1 clients.
335
336 -S
337 Use SRV lookups to determine which host to connect to. Performs
338 lookups to _mqtt._tcp.<host> when used in conjunction with -h,
339 otherwise uses _mqtt._tcp.<local dns domain>.
340
341 -t, --topic
342 The MQTT topic to subscribe to. See mqtt(7) for more information on
343 MQTT topics.
344
345 This option may be repeated to subscribe to multiple topics.
346
347 -T, --filter-out
348 Suppress printing of topics that match the filter. This allows
349 subscribing to a wildcard topic and only printing a partial set of
350 the wildcard hierarchy.
351
352 For example, subscribe to the BBC tree, but suppress output from
353 Radio 3:
354
355 • mosquitto_sub -t bbc/# -T bbc/radio3
356
357 This option may be repeated to filter out multiple topics or topic
358 trees.
359
360 --tls-alpn
361 Provide a protocol to use when connecting to a broker that has
362 multiple protocols available on a single port, e.g. MQTT and
363 WebSockets.
364
365 --tls-engine
366 A valid openssl engine id. These can be listed with openssl engine
367 command.
368
369 See also --keyform.
370
371 --tls-engine-kpass-sha1
372 SHA1 of the private key password when using an TLS engine. Some TLS
373 engines such as the TPM engine may require the use of a password in
374 order to be accessed. This option allows a hex encoded SHA1 hash of
375 the password to the engine directly, instead of the user being
376 prompted for the password.
377
378 See also --tls-engine.
379
380 --tls-use-os-certs
381 If used, this will load and trust the OS provided CA certificates.
382 This can be used in conjunction with --cafile and --capath and can
383 be used on its own to enable TLS mode. This will be set by default
384 if -L mqtts://... is used, or if port is 8883 and no other
385 certificate options are used.
386
387 --tls-version
388 Choose which TLS protocol version to use when communicating with
389 the broker. Valid options are tlsv1.3, tlsv1.2 and tlsv1.1. The
390 default value is tlsv1.2. Must match the protocol version used by
391 the broker.
392
393 -u, --username
394 Provide a username to be used for authenticating with the broker.
395 See also the --pw argument.
396
397 --unix
398 Connect to a broker through a local unix domain socket instead of a
399 TCP socket. This is a replacement for -h and -L. For example:
400 mosquitto_pub --unix /tmp/mosquitto.sock ...
401
402 See the socket_domain option in mosquitto.conf[1m(5) to configure
403 Mosquitto to listen on a unix socket.
404
405 -U, --unsubscribe
406 A topic that will be unsubscribed from. This may be used on its own
407 or in conjunction with the --topic option and only makes sense when
408 used in conjunction with --clean-session.
409
410 If used with --topic then subscriptions will be processed before
411 unsubscriptions.
412
413 Note that it is only possible to unsubscribe from subscriptions
414 that have previously been made. It is not possible to punch holes
415 in wildcard subscriptions. For example, subscribing to sensors/#
416 and then unsubscribing from sensors/+/temperature as shown below
417 will still result in messages matching the sensors/+/temperature
418 being delivered to the client.
419
420 • mosquitto_sub -t sensors/# -U sensors/+/temperature -v
421
422 Note also that because retained messages are published by the
423 broker on receipt of a SUBSCRIBE command, subscribing and
424 unsubscribing to the same topic may result in messages being
425 received at the client.
426
427 This option may be repeated to unsubscribe from multiple topics.
428
429 -v, --verbose
430 Print received messages verbosely. With this argument, messages
431 will be printed as "topic payload". When this argument is not
432 given, the messages are printed as "payload".
433
434 -V, --protocol-version
435 Specify which version of the MQTT protocol should be used when
436 connecting to the remote broker. Can be 5, 311, 31, or the more
437 verbose mqttv5, mqttv311, or mqttv31. Defaults to 311.
438
439 -W
440 Provide a timeout as an integer number of seconds. mosquitto_sub
441 will stop processing messages and disconnect after this number of
442 seconds has passed. The timeout starts just after the client has
443 connected to the broker.
444
445 --will-payload
446 Specify a message that will be stored by the broker and sent out if
447 this client disconnects unexpectedly. This must be used in
448 conjunction with --will-topic.
449
450 --will-qos
451 The QoS to use for the Will. Defaults to 0. This must be used in
452 conjunction with --will-topic.
453
454 --will-retain
455 If given, if the client disconnects unexpectedly the message sent
456 out will be treated as a retained message. This must be used in
457 conjunction with --will-topic.
458
459 --will-topic
460 The topic on which to send a Will, in the event that the client
461 disconnects unexpectedly.
462
463 -x
464 Set the session-expiry-interval property on the CONNECT packet.
465 Applies to MQTT v5 clients only. Set to 0-4294967294 to specify the
466 session will expire in that many seconds after the client
467 disconnects, or use -1, 4294967295, or ∞ for a session that does
468 not expire. Defaults to -1 if -c is also given, or 0 if -c not
469 given.
470
471 If the session is set to never expire, either with -x or -c, then a
472 client id must be provided.
473
475 There are three ways of formatting the output from mosquitto_sub. In
476 all cases a new-line character is appended for each message received
477 unless the -N argument is passed to mosquitto_sub.
478
479 Payload-only is the default output format and will print the payload
480 exactly as it is received.
481
482 Verbose mode is activated with -v and prints the message topic and the
483 payload, separated by a space.
484
485 The final option is formatted output, which allows the user to define a
486 custom output format. The behaviour is controlled with the -F
487 format-string option. The format string is a free text string where
488 interpreted sequences are replaced by different parameters. The
489 available interpreted sequences are described below.
490
491 Three characters are used to start an interpreted sequence: %, @ and \.
492 Sequences starting with % are either parameters related to the MQTT
493 message being printed, or are helper sequences to avoid the need to
494 type long date format strings for example. Sequences starting with @
495 are passed to the strftime(3) function (with the @ replaced with a % -
496 note that only the character immediately after the @ is passed to
497 strftime). This allows the construction of a wide variety of time based
498 outputs. The output options for strftime vary from platform to
499 platform, so please check what is available for your platform.
500 mosquitto_sub does provide one extension to strftime which is @N, which
501 can be used to obtain the number of nanoseconds passed in the current
502 second. The resolution of this option varies depending on the platform.
503 The final sequence character is \, which is used to input some
504 characters that would otherwise be difficult to enter.
505
506 Flag characters
507 The parameters %A, %C, %E, %F, %I, %l, %m, %p, %R, %S, %t, %x, and %X
508 can have optional flags immediately after the % character.
509
510 0
511 The value should be zero padded. This applies to the parameters %A,
512 %E, %F, %l, %m, %S, %X, and %x. It will be ignored for other
513 parameters. If used with the - flag, the 0 flag will be ignored.
514
515 -
516 The value will be left aligned to the field width, padded with
517 blanks. The default is right alignment, with either 0 or blank
518 padding.
519
520 Field width
521 Some of the MQTT related parameters can be formatted with an option to
522 set their field width in a similar way to regular printf style formats,
523 i.e. this sets the minimum width when printing this parameter. This
524 applies to the options %A, %C, %E, %F, %I, %l, %m, %p, %R, %S, %t, %x,
525 %X.
526
527 For example %10t would set the minimum topic field width to 10
528 characters.
529
530 Maximum width
531 Some of the MQTT related parameters can be formatted with an option to
532 set a maximum field width in a similar way to regular printf style
533 formats. This applies to the options %C, %I, %R, %t.
534
535 For example %10.10t would set the minimum topic field width to 10
536 characters, and the maximum topic width to 10 characters, i.e. the
537 field will always be exactly 10 characters long.
538
539 MQTT related parameters
540 • %% a literal %.
541
542 • %A the MQTT v5 topic-alias property, if present.
543
544 • %C the MQTT v5 content-type property, if present.
545
546 • %D the MQTT v5 correlation-data property, if present. Note that
547 this property is specified as binary data, so may produce
548 non-printable characters.
549
550 • %E the MQTT v5 message-expiry-interval property, if present.
551
552 • %F the MQTT v5 payload-format-indicator property, if present.
553
554 • %l the length of the payload in bytes.
555
556 • %m the message id (only relevant for messages with QoS>0).
557
558 • %P the MQTT v5 user-property property, if present. This will be
559 printed in the form key:value. It is possible for any number of
560 user properties to be attached to a message, and to have duplicate
561 keys.
562
563 • %p the payload raw bytes (may produce non-printable characters
564 depending on the payload).
565
566 • %q the message QoS.
567
568 • %R the MQTT v5 response-topic property, if present.
569
570 • %r the retained flag for the message.
571
572 • %S the MQTT v5 subscription-identifier property, if present.
573
574 • %t the message topic.
575
576 • %x the payload with each byte as a hexadecimal number (lower case).
577
578 • %X the payload with each byte as a hexadecimal number (upper case).
579
580 Helpers
581 • %I ISO-8601 format date and time, e.g. 2016-08-10T09:47:38+0100
582
583 • %j JSON output of message parameters and timestamp, with a quoted
584 and escaped payload. For example
585 {"tst":"2020-05-06T22:12:00.000000+0100","topic":"greeting","qos":0,"retain":0,"payload":"hello
586 world"}
587
588 • %J JSON output of message parameters and timestamp, with a
589 non-quoted and non-escaped payload - this means the payload must
590 itself be valid JSON. For example:
591 {"tst":"2020-05-06T22:12:00.000000+0100","topic":"foo","qos":0,"retain":0,"payload":{"temperature":27.0,"humidity":57}}.
592
593 If the payload is not valid JSON, then the error message "Error:
594 Message payload is not valid JSON on topic <topic>" will be printed
595 to stderr.
596
597 • %I ISO-8601 format date and time, e.g. 2016-08-10T09:47:38+0100
598
599 • %U Unix timestamp with nanoseconds, e.g. 1470818943.786368637
600
601 Time related parameters
602 • @@ a literal @.
603
604 • @X pass the character represented by X to the strftime function as
605 %X. The options supported are platform dependent.
606
607 • @N the number of nanoseconds that have passed in the current
608 second, with varying timing resolution depending on platform.
609
610 Escape characters
611 • \\ a literal \.
612
613 • \0 a null character. Can be used to separate different parameters
614 that may contain spaces (e.g. topic, payload) so that processing
615 with tools such as xargs(1) is easier.
616
617 • \a alert/bell.
618
619 • \e the escape sequence, which can be used with ANSI colour codes to
620 provide coloured output for example.
621
622 • \n end of line.
623
624 • \r carriage return.
625
626 • \t horizontal tab.
627
628 • \v vertical tab.
629
631 mosquitto_sub can register a message with the broker that will be sent
632 out if it disconnects unexpectedly. See mqtt(7) for more information.
633
634 The minimum requirement for this is to use --will-topic to specify
635 which topic the will should be sent out on. This will result in a
636 non-retained, zero length message with QoS 0.
637
638 Use the --will-retain, --will-payload and --will-qos arguments to
639 modify the other will parameters.
640
642 The -D / --property option allows adding properties to different stages
643 of the mosquitto_sub run. The properties supported for each command are
644 as follows:
645
646 Connect
647 • authentication-data (binary data - note treated as a string in
648 mosquitto_sub)
649
650 • authentication-method (UTF-8 string)
651
652 • maximum-packet-size (32-bit unsigned integer)
653
654 • receive-maximum (16-bit unsigned integer)
655
656 • request-problem-information (8-bit unsigned integer)
657
658 • request-response-information (8-bit unsigned integer)
659
660 • session-expiry-interval (32-bit unsigned integer, note use -x
661 instead)
662
663 • topic-alias-maximum (16-bit unsigned integer)
664
665 • user-property (UTF-8 string pair)
666
667 Subscribe
668 • user-property (UTF-8 string pair)
669
670 Unsubscribe
671 • user-property (UTF-8 string pair)
672
673 Disconnect
674 • session-expiry-interval (32-bit unsigned integer)
675
676 • user-property (UTF-8 string pair)
677
678 Will properties
679 • content-type (UTF-8 string)
680
681 • correlation-data (binary data - note treated as a string in
682 mosquitto_sub)
683
684 • message-expiry-interval (32-bit unsigned integer)
685
686 • payload-format-indicator (8-bit unsigned integer)
687
688 • response-topic (UTF-8 string)
689
690 • user-property (UTF-8 string pair)
691
692 • will-delay-interval (32-bit unsigned integer)
693
695 mosquitto_sub returns zero on success, or non-zero on error. If the
696 connection is refused by the broker at the MQTT level, then the exit
697 code is the CONNACK reason code. If another error occurs, the exit code
698 is a libmosquitto return value.
699
700 MQTT v3.1.1 CONNACK codes:
701
702 • 0 Success
703
704 • 1 Connection refused: Bad protocol version
705
706 • 2 Connection refused: Identifier rejected
707
708 • 3 Connection refused: Server unavailable
709
710 • 4 Connection refused: Bad username/password
711
712 • 5 Connection refused: Not authorized
713
714 MQTT v5 CONNACK codes:
715
716 • 0 Success
717
718 • 128 Unspecified error
719
720 • 129 Malformed packet
721
722 • 130 Protocol error
723
724 • 131 Implementation specific error
725
726 • 132 Unsupported protocol version
727
728 • 133 Client ID not valid
729
730 • 134 Bad username or password
731
732 • 135 Not authorized
733
734 • 136 Server unavailable
735
736 • 137 Server busy
737
738 • 138 Banned
739
740 • 139 Server shutting down
741
742 • 140 Bad authentication method
743
744 • 141 Keep alive timeout
745
746 • 142 Session taken over
747
748 • 143 Topic filter invalid
749
750 • 144 Topic name invalid
751
752 • 147 Receive maximum exceeded
753
754 • 148 Topic alias invalid
755
756 • 149 Packet too large
757
758 • 148 Message rate too high
759
760 • 151 Quota exceeded
761
762 • 152 Administrative action
763
764 • 153 Payload format invalid
765
766 • 154 Retain not supported
767
768 • 155 QoS not supported
769
770 • 156 Use another server
771
772 • 157 Server moved
773
774 • 158 Shared subscriptions not supported
775
776 • 159 Connection rate exceeded
777
778 • 160 Maximum connect time
779
780 • 161 Subscription IDs not supported
781
782 • 162 Wildcard subscriptions not supported
783
785 Note that these really are examples - the subscriptions will work if
786 you run them as shown, but there must be something publishing messages
787 on those topics for you to receive anything.
788
789 Subscribe to temperature information on localhost with QoS 1:
790
791 • mosquitto_sub -t sensors/temperature -q 1
792
793 Subscribe to hard drive temperature updates on multiple machines/hard
794 drives. This expects each machine to be publishing its hard drive
795 temperature to sensors/machines/HOSTNAME/temperature/HD_NAME.
796
797 • mosquitto_sub -t sensors/machines/+/temperature/+
798
799 Subscribe to all broker status messages:
800
801 • mosquitto_sub -v -t \$SYS/#
802
803 Specify the output format as "ISO-8601 date : topic : payload in hex"
804
805 • mosquitto_sub -F '@Y-@m-@dT@H:@M:@S@z : %t : %x' -t '#'
806
807 Specify the output format as "seconds since epoch.nanoseconds :
808 retained flag : qos : mid : payload length"
809
810 • mosquitto_sub -F '%@s.@N : %r : %q : %m : %l' -q 2 -t '#'
811
812 Topic and payload output, but with colour where supported.
813
814 • mosquitto_sub -F '\e[92m%t \e[96m%p\e[0m' -q 2 -t '#'
815
817 0
818 Success
819
820 27
821 Timed out waiting for message
822
823 Other non-zero value
824 Unspecified failure
825
827 $XDG_CONFIG_HOME/mosquitto_sub, $HOME/.config/mosquitto_sub
828 Configuration file for default options.
829
831 mosquitto bug information can be found at
832 https://github.com/eclipse/mosquitto/issues
833
835 mqtt(7), mosquitto_pub(1), mosquitto_rr(1), mosquitto(8),
836 libmosquitto(3), mosquitto-tls(7)
837
839 Roger Light <roger@atchoo.org>
840
841
842
843Mosquitto Project 08/16/2022 MOSQUITTO_SUB(1)