1MOSQUITTO_RR(1)                    Commands                    MOSQUITTO_RR(1)
2
3
4

NAME

6       mosquitto_rr - an MQTT version 5/3.1.1 client for request/response
7       messaging
8

SYNOPSIS

10       mosquitto_rr -e response-topic
11                    {[-h hostname] [--unix socket path] [-p port-number] [-u username] [-P password] -t message-topic...
12                    | -L URL [-t message-topic...] } {-f file | -m message |
13                    -n | -s} [-A bind-address] [-c] [-d]
14                    [-D command identifier value] [-i client-id]
15                    [-I client-id-prefix] [-k keepalive-time] [-N] [--nodelay]
16                    [--pretty] [-q message-QoS] [-R] [-S] [-v]
17                    [-V protocol-version] [-W message-processing-timeout]
18                    [-x session-expiry-interval] [--proxy socks-url] [--quiet]
19                    [--will-topic topic [--will-payload payload] [--will-qos qos] [--will-retain]]
20                    [[{--cafile file | --capath dir} [--cert file] [--key file] [--ciphers ciphers] [--tls-version version] [--tls-alpn protocol] [--tls-engine engine] [--keyform {pem | engine}] [--tls-engine-kpass-sha1 kpass-sha1] [--tls-use-os-certs] [--insecure]]
21                    |
22                    [--psk hex-key --psk-identity identity [--ciphers ciphers] [--tls-version version]]]
23
24       mosquitto_rr [--help]
25

DESCRIPTION

27       mosquitto_rr is an MQTT version 5/3.1.1 client that can be used to
28       publish a request message and wait for a response. When using MQTT v5,
29       which is the default, mosquitto_rr will use the Request-Response
30       feature.
31
32       The important options are -t, -e, and one of -f, -m, -n, and -s.
33
34       Example: mosquitto_rr -t request-topic -e response-topic -m message
35

ENCRYPTED CONNECTIONS

37       mosquitto_rr supports TLS encrypted connections. It is strongly
38       recommended that you use an encrypted connection for anything more than
39       the most basic setup.
40
41       To enable TLS connections when using x509 certificates, one of either
42       --cafile or --capath can be provided as an option.
43
44       Alternatively, if the -p 8883 option is used then the OS provided
45       certificates will be loaded and neither --cafile or --capath are needed
46
47       To enable TLS connections when using TLS-PSK, you must use the --psk
48       and the --psk-identity options.
49

OPTIONS

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

OUTPUT FORMAT

393       There are three ways of formatting the output from mosquitto_rr. In all
394       cases a new-line character is appended for each message received unless
395       the -N argument is passed to mosquitto_rr.
396
397       Payload-only is the default output format and will print the payload
398       exactly as it is received.
399
400       Verbose mode is activated with -v and prints the message topic and the
401       payload, separated by a space.
402
403       The final option is formatted output, which allows the user to define a
404       custom output format. The behaviour is controlled with the -F
405       format-string option. The format string is a free text string where
406       interpreted sequences are replaced by different parameters. The
407       available interpreted sequences are described below.
408
409       Three characters are used to start an interpreted sequence: %, @ and \.
410       Sequences starting with % are either parameters related to the MQTT
411       message being printed, or are helper sequences to avoid the need to
412       type long date format strings for example. Sequences starting with @
413       are passed to the strftime(3) function (with the @ replaced with a % -
414       note that only the character immediately after the @ is passed to
415       strftime). This allows the construction of a wide variety of time based
416       outputs. The output options for strftime vary from platform to
417       platform, so please check what is available for your platform.
418       mosquitto_rr does provide one extension to strftime which is @N, which
419       can be used to obtain the number of nanoseconds passed in the current
420       second. The resolution of this option varies depending on the platform.
421       The final sequence character is \, which is used to input some
422       characters that would otherwise be difficult to enter.
423
424   MQTT related parameters
425%% a literal %.
426
427%A the MQTT v5 topic-alias property, if present.
428
429%C the MQTT v5 content-type property, if present.
430
431%D the MQTT v5 correlation-data property, if present. Note that
432           this property is specified as binary data, so may produce
433           non-printable characters.
434
435%E the MQTT v5 message-expiry-interval property, if present.
436
437%F the MQTT v5 payload-format-indicator property, if present.
438
439%l the length of the payload in bytes.
440
441%m the message id (only relevant for messages with QoS>0).
442
443%P the MQTT v5 user-property property, if present. This will be
444           printed in the form key:value. It is possible for any number of
445           user properties to be attached to a message, and to have duplicate
446           keys.
447
448%p the payload raw bytes (may produce non-printable characters
449           depending on the payload).
450
451%q the message QoS.
452
453%R the MQTT v5 response-topic property, if present.
454
455%r the retained flag for the message.
456
457%S the MQTT v5 subscription-identifier property, if present.
458
459%t the message topic.
460
461%x the payload with each byte as a hexadecimal number (lower case).
462
463%X the payload with each byte as a hexadecimal number (upper case).
464
465   Helpers
466%I ISO-8601 format date and time, e.g. 2016-08-10T09:47:38+0100
467
468%j JSON output of message parameters and timestamp, with a quoted
469           and escaped payload. For example
470           {"tst":"2020-05-06T22:12:00.000000+0100","topic":"greeting","qos":0,"retain":0,"payload":"hello
471           world"}
472
473%J JSON output of message parameters and timestamp, with a
474           non-quoted and non-escaped payload - this means the payload must
475           itself be valid JSON. For example:
476           {"tst":"2020-05-06T22:12:00.000000+0100","topic":"foo","qos":0,"retain":0,"payload":{"temperature":27.0,"humidity":57}}.
477
478           If the payload is not valid JSON, then the error message "Error:
479           Message payload is not valid JSON on topic <topic>" will be printed
480           to stderr.
481
482%I ISO-8601 format date and time, e.g. 2016-08-10T09:47:38+0100
483
484%U Unix timestamp with nanoseconds, e.g. 1470818943.786368637
485
486   Time related parameters
487@@ a literal @.
488
489@X pass the character represented by X to the strftime function as
490           %X. The options supported are platform dependent.
491
492@N the number of nanoseconds that have passed in the current
493           second, with varying timing resolution depending on platform.
494
495   Escape characters
496\\ a literal \.
497
498\0 a null character. Can be used to separate different parameters
499           that may contain spaces (e.g. topic, payload) so that processing
500           with tools such as xargs(1) is easier.
501
502\a alert/bell.
503
504\e the escape sequence, which can be used with ANSI colour codes to
505           provide coloured output for example.
506
507\n end of line.
508
509\r carriage return.
510
511\t horizontal tab.
512
513\v vertical tab.
514

WILLS

516       mosquitto_rr can register a message with the broker that will be sent
517       out if it disconnects unexpectedly. See mqtt(7) for more information.
518
519       The minimum requirement for this is to use --will-topic to specify
520       which topic the will should be sent out on. This will result in a
521       non-retained, zero length message with QoS 0.
522
523       Use the --will-retain, --will-payload and --will-qos arguments to
524       modify the other will parameters.
525

PROPERTIES

527       The -D / --property option allows adding properties to different stages
528       of the mosquitto_rr run. The properties supported for each command are
529       as follows:
530
531   Connect
532authentication-data (binary data - note treated as a string in
533           mosquitto_rr)
534
535authentication-method (UTF-8 string pair)
536
537maximum-packet-size (32-bit unsigned integer)
538
539receive-maximum (16-bit unsigned integer)
540
541request-problem-information (8-bit unsigned integer)
542
543request-response-information (8-bit unsigned integer)
544
545session-expiry-interval (32-bit unsigned integer, note use -x
546           instead)
547
548topic-alias-maximum (16-bit unsigned integer)
549
550user-property (UTF-8 string pair)
551
552   Publish
553content-type (UTF-8 string)
554
555correlation-data (binary data - note treated as a string in
556           mosquitto_rr)
557
558message-expiry-interval (32-bit unsigned integer)
559
560payload-format-indicator (8-bit unsigned integer)
561
562response-topic (UTF-8 string)
563
564topic-alias (16-bit unsigned integer)
565
566user-property (UTF-8 string pair)
567
568   Subscribe
569user-property (UTF-8 string pair)
570
571   Unsubscribe
572user-property (UTF-8 string pair)
573
574   Disconnect
575session-expiry-interval (32-bit unsigned integer)
576
577user-property (UTF-8 string pair)
578
579   Will properties
580content-type (UTF-8 string)
581
582correlation-data (binary data - note treated as a string in
583           mosquitto_pub)
584
585message-expiry-interval (32-bit unsigned integer)
586
587payload-format-indicator (8-bit unsigned integer)
588
589response-topic (UTF-8 string)
590
591user-property (UTF-8 string pair)
592
593will-delay-interval (32-bit unsigned integer)
594

EXIT VALUES

596       0
597           Success
598
599       27
600           Timed out waiting for message
601
602       Other non-zero value
603           Unspecified failure
604

FILES

606       $XDG_CONFIG_HOME/mosquitto_rr, $HOME/.config/mosquitto_rr
607           Configuration file for default options.
608

BUGS

610       mosquitto bug information can be found at
611       https://github.com/eclipse/mosquitto/issues
612

SEE ALSO

614       mqtt(7), mosquitto_pub(1), mosquitto_sub(1), mosquitto(8),
615       libmosquitto(3), mosquitto-tls(7)
616

AUTHOR

618       Roger Light <roger@atchoo.org>
619
620
621
622Mosquitto Project                 09/18/2023                   MOSQUITTO_RR(1)
Impressum