mosquitto_sub.1 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964
  1. '\" t
  2. .\" Title: mosquitto_sub
  3. .\" Author: [see the "Author" section]
  4. .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
  5. .\" Date: 10/27/2021
  6. .\" Manual: Commands
  7. .\" Source: Mosquitto Project
  8. .\" Language: English
  9. .\"
  10. .TH "MOSQUITTO_SUB" "1" "10/27/2021" "Mosquitto Project" "Commands"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. mosquitto_sub \- an MQTT version 5/3\&.1\&.1/3\&.1 client for subscribing to topics
  32. .SH "SYNOPSIS"
  33. .HP \w'\fBmosquitto_sub\fR\ 'u
  34. \fBmosquitto_sub\fR {[\fB\-h\fR\ \fIhostname\fR]\ [\fB\-\-unix\fR\ \fIsocket\ path\fR]\ [\fB\-p\fR\ \fIport\-number\fR]\ [\fB\-u\fR\ \fIusername\fR]\ [\fB\-P\fR\ \fIpassword\fR]\ \fB\-t\fR\ \fImessage\-topic\fR... | \fB\-L\fR\ \fIURL\fR\ [\fB\-t\fR\ \fImessage\-topic\fR...] } [\fB\-A\fR\ \fIbind\-address\fR] [\fB\-c\fR] [\fB\-C\fR\ \fImsg\-count\fR] [\fB\-d\fR] [\fB\-D\fR\ \fIcommand\fR\ \fIidentifier\fR\ \fIvalue\fR] [\fB\-E\fR] [\fB\-i\fR\ \fIclient\-id\fR] [\fB\-I\fR\ \fIclient\-id\-prefix\fR] [\fB\-k\fR\ \fIkeepalive\-time\fR] [\fB\-N\fR] [\fB\-\-nodelay\fR] [\fB\-\-pretty\fR] [\fB\-q\fR\ \fImessage\-QoS\fR] [\fB\-\-random\-filter\fR\ \fIchance\fR] [\fB\-\-remove\-retained\fR] [\fB\-R\fR | \fB\-\-retained\-only\fR] [\fB\-\-retain\-as\-published\fR] [\fB\-S\fR] [\fB\-T\fR\ \fIfilter\-out\fR...] [\fB\-U\fR\ \fIunsub\-topic\fR...] [\fB\-v\fR] [\fB\-V\fR\ \fIprotocol\-version\fR] [\fB\-W\fR\ \fImessage\-processing\-timeout\fR] [\fB\-x\fR\ \fIsession\-expiry\-interval\fR] [\fB\-\-proxy\fR\ \fIsocks\-url\fR] [\fB\-\-quiet\fR] [\fB\-\-will\-topic\fR\ \fItopic\fR\ [\fB\-\-will\-payload\fR\ \fIpayload\fR]\ [\fB\-\-will\-qos\fR\ \fIqos\fR]\ [\fB\-\-will\-retain\fR]] [[{\fB\-\-cafile\fR\ \fIfile\fR\ |\ \fB\-\-capath\fR\ \fIdir\fR}\ [\fB\-\-cert\fR\ \fIfile\fR]\ [\fB\-\-key\fR\ \fIfile\fR]\ [\fB\-\-tls\-version\fR\ \fIversion\fR]\ [\fB\-\-tls\-alpn\fR\ \fIprotocol\fR]\ [\fB\-\-tls\-engine\fR\ \fIengine\fR]\ [\fB\-\-keyform\fR\ {\fIpem\fR\ |\ \fIengine\fR}]\ [\fB\-\-tls\-engine\-kpass\-sha1\fR\ \fIkpass\-sha1\fR]\ [\fB\-\-tls\-use\-os\-certs\fR]\ [\fB\-\-insecure\fR]] | [\fB\-\-psk\fR\ \fIhex\-key\fR\ \fB\-\-psk\-identity\fR\ \fIidentity\fR\ [\fB\-\-tls\-version\fR\ \fIversion\fR]]]
  35. .HP \w'\fBmosquitto_sub\fR\ 'u
  36. \fBmosquitto_sub\fR [\fB\-\-help\fR]
  37. .SH "DESCRIPTION"
  38. .PP
  39. \fBmosquitto_sub\fR
  40. is a simple MQTT version 5/3\&.1\&.1 client that will subscribe to topics and print the messages that it receives\&.
  41. .PP
  42. In addition to subscribing to topics,
  43. \fBmosquitto_sub\fR
  44. can filter out received messages so they are not printed (see the
  45. \fB\-T\fR
  46. option) or unsubscribe from topics (see the
  47. \fB\-U\fR
  48. option)\&. Unsubscribing from topics is useful for clients connecting with clean session set to false\&.
  49. .SH "ENCRYPTED CONNECTIONS"
  50. .PP
  51. \fBmosquitto_sub\fR
  52. supports TLS encrypted connections\&. It is strongly recommended that you use an encrypted connection for anything more than the most basic setup\&.
  53. .PP
  54. To enable TLS connections when using x509 certificates, one of either
  55. \fB\-\-cafile\fR
  56. or
  57. \fB\-\-capath\fR
  58. can be provided as an option\&.
  59. .PP
  60. Alternatively, if the
  61. \fB\-p 8883\fR
  62. option is used then the OS provided certificates will be loaded and neither
  63. \fB\-\-cafile\fR
  64. or
  65. \fB\-\-capath\fR
  66. are needed
  67. .PP
  68. To enable TLS connections when using TLS\-PSK, you must use the
  69. \fB\-\-psk\fR
  70. and the
  71. \fB\-\-psk\-identity\fR
  72. options\&.
  73. .SH "OPTIONS"
  74. .PP
  75. The options below may be given on the command line, but may also be placed in a config file located at
  76. \fB$XDG_CONFIG_HOME/mosquitto_sub\fR
  77. or
  78. \fB$HOME/\&.config/mosquitto_sub\fR
  79. with one pair of
  80. \fB\-option \fR\fB\fIvalue\fR\fR
  81. per line\&. The values in the config file will be used as defaults and can be overridden by using the command line\&. The exceptions to this are
  82. \fB\-t\fR
  83. and
  84. \fB\-T\fR, which if given in the config file will not be overridden\&. Note also that currently some options cannot be negated, e\&.g\&.
  85. \fB\-S\fR\&. Config file lines that have a
  86. \fB#\fR
  87. as the first character are treated as comments and not processed any further\&.
  88. .PP
  89. \fB\-A\fR
  90. .RS 4
  91. Bind the outgoing connection to a local ip address/hostname\&. Use this argument if you need to restrict network communication to a particular interface\&.
  92. .RE
  93. .PP
  94. \fB\-c\fR, \fB\-\-disable\-clean\-session\fR
  95. .RS 4
  96. Disable \*(Aqclean session\*(Aq / enable persistent client mode\&. When this argument is used, the broker will be instructed not to clean existing sessions for the same client id when the client connects, and sessions will never expire when the client disconnects\&. MQTT v5 clients can change their session expiry interval with the
  97. \fB\-x\fR
  98. argument\&.
  99. .sp
  100. When a session is persisted on the broker, 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 and does not clean the session, it will receive all of the queued messages\&.
  101. .sp
  102. If using this option, the client id must be set manually with
  103. \fB\-\-id\fR
  104. .RE
  105. .PP
  106. \fB\-\-cafile\fR
  107. .RS 4
  108. Define the path to a file containing PEM encoded CA certificates that are trusted\&. Used to enable SSL communication\&.
  109. .sp
  110. See also
  111. \fB\-\-capath\fR
  112. .RE
  113. .PP
  114. \fB\-\-capath\fR
  115. .RS 4
  116. Define the path to a directory containing PEM encoded CA certificates that are trusted\&. Used to enable SSL communication\&.
  117. .sp
  118. For
  119. \fB\-\-capath\fR
  120. to work correctly, the certificate files must have "\&.crt" as the file ending and you must run "openssl rehash <path to capath>" each time you add/remove a certificate\&.
  121. .sp
  122. See also
  123. \fB\-\-cafile\fR
  124. .RE
  125. .PP
  126. \fB\-\-cert\fR
  127. .RS 4
  128. Define the path to a file containing a PEM encoded certificate for this client, if required by the server\&.
  129. .sp
  130. See also
  131. \fB\-\-key\fR\&.
  132. .RE
  133. .PP
  134. \fB\-\-ciphers\fR
  135. .RS 4
  136. An openssl compatible list of TLS ciphers to support in the client\&. See
  137. \fBciphers\fR(1)
  138. for more information\&.
  139. .RE
  140. .PP
  141. \fB\-C\fR
  142. .RS 4
  143. Disconnect and exit the program immediately after the given count of messages have been received\&. This may be useful in shell scripts where on a single status value is required, for example\&.
  144. .sp
  145. Combine with
  146. \fB\-R\fR
  147. to print only the first set of fresh messages (i\&.e\&. that does not have the retained flag set), or with
  148. \fB\-T\fR
  149. to filter which topics are processed\&.
  150. .RE
  151. .PP
  152. \fB\-d\fR, \fB\-\-debug\fR
  153. .RS 4
  154. Enable debug messages\&.
  155. .RE
  156. .PP
  157. \fB\-D\fR, \fB\-\-property\fR
  158. .RS 4
  159. Use an MQTT v5 property with this publish\&. If you use this option, the client will be set to be an MQTT v5 client\&. This option has two forms:
  160. .sp
  161. \fB\-D command identifier value\fR
  162. .sp
  163. \fB\-D command identifier name value\fR
  164. .sp
  165. \fBcommand\fR
  166. is the MQTT command/packet identifier and can be one of CONNECT, PUBACK, PUBREC, PUBCOMP, SUBSCRIBE, UNSUBSCRIBE, DISCONNECT, AUTH, or WILL\&. The properties available for each command are listed in the Properties section\&.
  167. .sp
  168. \fBidentifier\fR
  169. is the name of the property to add\&. This is as described in the specification, but with \*(Aq\-\*(Aq as a word separator\&. For example:
  170. \fBpayload\-format\-indicator\fR\&. More details are in the
  171. Properties
  172. section\&.
  173. .sp
  174. \fBvalue\fR
  175. is the value of the property to add, with a data type that is property specific\&.
  176. .sp
  177. \fBname\fR
  178. is only used for the
  179. \fBuser\-property\fR
  180. property as the first of the two strings in the string pair\&. In that case,
  181. \fBvalue\fR
  182. is the second of the strings in the pair\&.
  183. .RE
  184. .PP
  185. \fB\-E\fR
  186. .RS 4
  187. If this option is given,
  188. \fBmosquitto_sub\fR
  189. will exit immediately that all of its subscriptions have been acknowledged by the broker\&. In conjunction with
  190. \fB\-c\fR
  191. this allows a durable client session to be initialised on the broker for future use without requiring any messages to be received\&.
  192. .RE
  193. .PP
  194. \fB\-F\fR
  195. .RS 4
  196. Specify output printing format\&. This option allows you to choose what information from each message is printed to the screen\&. See the
  197. Output Format
  198. section below for full details\&.
  199. .sp
  200. This option overrides the
  201. \fB\-v\fR
  202. option, but does not override the
  203. \fB\-N\fR
  204. option\&.
  205. .RE
  206. .PP
  207. \fB\-\-help\fR
  208. .RS 4
  209. Display usage information\&.
  210. .RE
  211. .PP
  212. \fB\-h\fR, \fB\-\-host\fR
  213. .RS 4
  214. Specify the host to connect to\&. Defaults to localhost\&.
  215. .RE
  216. .PP
  217. \fB\-i\fR, \fB\-\-id\fR
  218. .RS 4
  219. The id to use for this client\&. If not given, a client id will be generated depending on the MQTT version being used\&. For v3\&.1\&.1/v3\&.1, the client generates a client id in the format
  220. \fBmosq\-XXXXXXXXXXXXXXXXXX\fR, where the
  221. \fBX\fR
  222. are replaced with random alphanumeric characters\&. For v5\&.0, the client sends a zero length client id, and the server will generate a client id for the client\&.
  223. .sp
  224. This option cannot be used at the same time as the
  225. \fB\-\-id\-prefix\fR
  226. argument\&.
  227. .RE
  228. .PP
  229. \fB\-I\fR, \fB\-\-id\-prefix\fR
  230. .RS 4
  231. 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
  232. \fB\-\-id\fR
  233. argument\&.
  234. .RE
  235. .PP
  236. \fB\-\-insecure\fR
  237. .RS 4
  238. When using certificate based encryption, this option disables verification of the server hostname in the server certificate\&. This can be useful when testing initial server configurations but makes it possible for a malicious third party to impersonate your server through DNS spoofing, for example\&. Use this option in testing
  239. \fIonly\fR\&. If you need to resort to using this option in a production environment, your setup is at fault and there is no point using encryption\&.
  240. .RE
  241. .PP
  242. \fB\-k\fR, \fB\-\-keepalive\fR
  243. .RS 4
  244. 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\&.
  245. .RE
  246. .PP
  247. \fB\-\-key\fR
  248. .RS 4
  249. Define the path to a file containing a PEM encoded private key for this client, if required by the server\&.
  250. .sp
  251. See also
  252. \fB\-\-cert\fR\&.
  253. .RE
  254. .PP
  255. \fB\-\-keyform\fR
  256. .RS 4
  257. Specifies the type of private key in use when making TLS connections\&.\&. This can be "pem" or "engine"\&. This parameter is useful when a TPM module is being used and the private key has been created with it\&. Defaults to "pem", which means normal private key files are used\&.
  258. .sp
  259. See also
  260. \fB\-\-tls\-engine\fR\&.
  261. .RE
  262. .PP
  263. \fB\-L\fR, \fB\-\-url\fR
  264. .RS 4
  265. Specify specify user, password, hostname, port and topic at once as a URL\&. The URL must be in the form: mqtt(s)://[username[:password]@]host[:port]/topic
  266. .sp
  267. If the scheme is mqtt:// then the port defaults to 1883\&. If the scheme is mqtts:// then the port defaults to 8883\&.
  268. .RE
  269. .PP
  270. \fB\-N\fR
  271. .RS 4
  272. Do not append an end of line character to the payload when printing\&. This allows streaming of payload data from multiple messages directly to another application unmodified\&. Only really makes sense when not using
  273. \fB\-v\fR\&.
  274. .RE
  275. .PP
  276. \fB\-\-nodelay\fR
  277. .RS 4
  278. Disable Nagle\*(Aqs algorithm for the socket\&. This means that latency of sent messages is reduced, which is particularly noticeable for small, reasonably infrequent messages\&. Using this option may result in more packets being sent than would normally be necessary\&.
  279. .RE
  280. .PP
  281. \fB\-p\fR, \fB\-\-port\fR
  282. .RS 4
  283. Connect to the port specified\&. If not given, the default of 1883 for plain MQTT or 8883 for MQTT over TLS will be used\&.
  284. .RE
  285. .PP
  286. \fB\-P\fR, \fB\-\-pw\fR
  287. .RS 4
  288. Provide a password to be used for authenticating with the broker\&. Using this argument without also specifying a username is invalid when using MQTT v3\&.1 or v3\&.1\&.1\&. See also the
  289. \fB\-\-username\fR
  290. option\&.
  291. .RE
  292. .PP
  293. \fB\-\-pretty\fR
  294. .RS 4
  295. When using the JSON output format %j or %J, the default is to print in an unformatted fashion\&. Specifying
  296. \fB\-\-pretty\fR
  297. prints messages in a prettier, more human readable format\&.
  298. .RE
  299. .PP
  300. \fB\-\-proxy\fR
  301. .RS 4
  302. Specify a SOCKS5 proxy to connect through\&. "None" and "username" authentication types are supported\&. The
  303. \fBsocks\-url\fR
  304. must be of the form
  305. \fBsocks5h://[username[:password]@]host[:port]\fR\&. The protocol prefix
  306. \fBsocks5h\fR
  307. means that hostnames are resolved by the proxy\&. The symbols %25, %3A and %40 are URL decoded into %, : and @ respectively, if present in the username or password\&.
  308. .sp
  309. If username is not given, then no authentication is attempted\&. If the port is not given, then the default of 1080 is used\&.
  310. .sp
  311. More SOCKS versions may be available in the future, depending on demand, and will use different protocol prefixes as described in
  312. \fBcurl\fR(1)\&.
  313. .RE
  314. .PP
  315. \fB\-\-psk\fR
  316. .RS 4
  317. Provide the hexadecimal (no leading 0x) pre\-shared\-key matching the one used on the broker to use TLS\-PSK encryption support\&.
  318. \fB\-\-psk\-identity\fR
  319. must also be provided to enable TLS\-PSK\&.
  320. .RE
  321. .PP
  322. \fB\-\-psk\-identity\fR
  323. .RS 4
  324. The client identity to use with TLS\-PSK support\&. This may be used instead of a username if the broker is configured to do so\&.
  325. .RE
  326. .PP
  327. \fB\-q\fR, \fB\-\-qos\fR
  328. .RS 4
  329. Specify the quality of service desired for the incoming messages, from 0, 1 and 2\&. Defaults to 0\&. See
  330. \fBmqtt\fR(7)
  331. for more information on QoS\&.
  332. .sp
  333. The QoS is identical for all topics subscribed to in a single instance of mosquitto_sub\&.
  334. .RE
  335. .PP
  336. \fB\-\-quiet\fR
  337. .RS 4
  338. 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
  339. \fB\-\-port\fR
  340. without a port)\&.
  341. .RE
  342. .PP
  343. \fB\-R\fR
  344. .RS 4
  345. If this argument is given, messages that are received that have the retain bit set will not be printed\&. Messages with retain set are "stale", in that it is not known when they were originally published\&. When subscribing to a wildcard topic there may be a large number of retained messages\&. This argument suppresses their display\&.
  346. .RE
  347. .PP
  348. \fB\-\-random\-filter\fR
  349. .RS 4
  350. This option can be used to reduce the proportion of messages that mosquitto_sub prints\&. The default behaviour is to print all incoming messages\&. Setting the
  351. \fIchance\fR
  352. to a floating point value between 0\&.1 and 100\&.0 will ensure that on average that percentage of messages will be printed\&.
  353. .RE
  354. .PP
  355. \fB\-\-remove\-retained\fR
  356. .RS 4
  357. If this argument is given, the when mosquitto_sub receives a message with the retained bit set, it will send a message to the broker to clear that retained message\&. This applies to all received messages except those that are filtered out by the
  358. \fB\-T\fR
  359. option\&. This option still takes effect even if
  360. \fB\-R\fR
  361. is used\&. See also the
  362. \fB\-\-retain\-as\-published\fR
  363. and
  364. \fB\-\-retained\-only\fR
  365. options\&.
  366. .PP
  367. \fBExample\ \&1.\ \&\fR
  368. Remove all retained messages on the server, assuming we have access to do so, and then exit:
  369. .sp
  370. .if n \{\
  371. .RS 4
  372. .\}
  373. .nf
  374. mosquitto_sub \-t \*(Aq#\*(Aq \-\-remove\-retained \-\-retained\-only
  375. .fi
  376. .if n \{\
  377. .RE
  378. .\}
  379. .PP
  380. \fBExample\ \&2.\ \&\fR
  381. Remove a whole tree, with the exception of a single topic:
  382. .sp
  383. .if n \{\
  384. .RS 4
  385. .\}
  386. .nf
  387. mosquitto_sub \-t \*(Aqbbc/#\*(Aq \-T bbc/bbc1 \-\-remove\-retained
  388. .fi
  389. .if n \{\
  390. .RE
  391. .\}
  392. .RE
  393. .PP
  394. \fB\-\-retained\-only\fR
  395. .RS 4
  396. If this argument is given, only messages that are received that have the retain bit set will be printed\&. Messages with retain set are "stale", in that it is not known when they were originally published\&. With this argument in use, the receipt of the first non\-stale message will cause the client to exit\&. See also the
  397. \fB\-\-retain\-as\-published\fR
  398. option\&.
  399. .RE
  400. .PP
  401. \fB\-\-retain\-as\-published\fR
  402. .RS 4
  403. If this argument is given, the subscriptions will have the "retain as published" option set\&. This means that the retain flag on an incoming message will be exactly as set by the publishing client, rather than indicating whether the message is fresh/stale\&.
  404. .sp
  405. This option is not valid for MQTT v3\&.1/v3\&.1\&.1 clients\&.
  406. .RE
  407. .PP
  408. \fB\-S\fR
  409. .RS 4
  410. Use SRV lookups to determine which host to connect to\&. Performs lookups to
  411. \fB_mqtt\&._tcp\&.<host>\fR
  412. when used in conjunction with
  413. \fB\-h\fR, otherwise uses
  414. \fB_mqtt\&._tcp\&.<local dns domain>\fR\&.
  415. .RE
  416. .PP
  417. \fB\-t\fR, \fB\-\-topic\fR
  418. .RS 4
  419. The MQTT topic to subscribe to\&. See
  420. \fBmqtt\fR(7)
  421. for more information on MQTT topics\&.
  422. .sp
  423. This option may be repeated to subscribe to multiple topics\&.
  424. .RE
  425. .PP
  426. \fB\-T\fR, \fB\-\-filter\-out\fR
  427. .RS 4
  428. Suppress printing of topics that match the filter\&. This allows subscribing to a wildcard topic and only printing a partial set of the wildcard hierarchy\&.
  429. .sp
  430. For example, subscribe to the BBC tree, but suppress output from Radio 3:
  431. .sp
  432. .RS 4
  433. .ie n \{\
  434. \h'-04'\(bu\h'+03'\c
  435. .\}
  436. .el \{\
  437. .sp -1
  438. .IP \(bu 2.3
  439. .\}
  440. mosquitto_sub
  441. \-t
  442. bbc/#
  443. \-T
  444. bbc/radio3
  445. .RE
  446. .sp
  447. This option may be repeated to filter out multiple topics or topic trees\&.
  448. .RE
  449. .PP
  450. \fB\-\-tls\-alpn\fR
  451. .RS 4
  452. Provide a protocol to use when connecting to a broker that has multiple protocols available on a single port, e\&.g\&. MQTT and WebSockets\&.
  453. .RE
  454. .PP
  455. \fB\-\-tls\-engine\fR
  456. .RS 4
  457. A valid openssl engine id\&. These can be listed with openssl engine command\&.
  458. .sp
  459. See also
  460. \fB\-\-keyform\fR\&.
  461. .RE
  462. .PP
  463. \fB\-\-tls\-engine\-kpass\-sha1\fR
  464. .RS 4
  465. SHA1 of the private key password when using an TLS engine\&. Some TLS engines such as the TPM engine may require the use of a password in order to be accessed\&. This option allows a hex encoded SHA1 hash of the password to the engine directly, instead of the user being prompted for the password\&.
  466. .sp
  467. See also
  468. \fB\-\-tls\-engine\fR\&.
  469. .RE
  470. .PP
  471. \fB\-\-tls\-use\-os\-certs\fR
  472. .RS 4
  473. If used, this will load and trust the OS provided CA certificates\&. This can be used in conjunction with
  474. \fB\-\-cafile\fR
  475. and
  476. \fB\-\-capath\fR
  477. and can be used on its own to enable TLS mode\&. This will be set by default if
  478. \fB\-L mqtts://\&.\&.\&.\fR
  479. is used, or if port is 8883 and no other certificate options are used\&.
  480. .RE
  481. .PP
  482. \fB\-\-tls\-version\fR
  483. .RS 4
  484. Choose which TLS protocol version to use when communicating with the broker\&. Valid options are
  485. \fBtlsv1\&.3\fR,
  486. \fBtlsv1\&.2\fR
  487. and
  488. \fBtlsv1\&.1\fR\&. The default value is
  489. \fBtlsv1\&.2\fR\&. Must match the protocol version used by the broker\&.
  490. .RE
  491. .PP
  492. \fB\-u\fR, \fB\-\-username\fR
  493. .RS 4
  494. Provide a username to be used for authenticating with the broker\&. See also the
  495. \fB\-\-pw\fR
  496. argument\&.
  497. .RE
  498. .PP
  499. \fB\-\-unix\fR
  500. .RS 4
  501. Connect to a broker through a local unix domain socket instead of a TCP socket\&. This is a replacement for
  502. \fB\-h\fR
  503. and
  504. \fB\-L\fR\&. For example:
  505. \fBmosquitto_pub \-\-unix /tmp/mosquitto\&.sock \&.\&.\&.\fR
  506. .sp
  507. See the
  508. \fBsocket_domain\fR
  509. option in
  510. \m[blue]\fBmosquitto\&.conf\fR\m[](5)
  511. to configure Mosquitto to listen on a unix socket\&.
  512. .RE
  513. .PP
  514. \fB\-U\fR, \fB\-\-unsubscribe\fR
  515. .RS 4
  516. A topic that will be unsubscribed from\&. This may be used on its own or in conjunction with the
  517. \fB\-\-topic\fR
  518. option and only makes sense when used in conjunction with
  519. \fB\-\-clean\-session\fR\&.
  520. .sp
  521. If used with
  522. \fB\-\-topic\fR
  523. then subscriptions will be processed before unsubscriptions\&.
  524. .sp
  525. Note that it is only possible to unsubscribe from subscriptions that have previously been made\&. It is not possible to punch holes in wildcard subscriptions\&. For example, subscribing to
  526. \fBsensors/#\fR
  527. and then unsubscribing from
  528. \fBsensors/+/temperature\fR
  529. as shown below will still result in messages matching the
  530. \fBsensors/+/temperature\fR
  531. being delivered to the client\&.
  532. .sp
  533. .RS 4
  534. .ie n \{\
  535. \h'-04'\(bu\h'+03'\c
  536. .\}
  537. .el \{\
  538. .sp -1
  539. .IP \(bu 2.3
  540. .\}
  541. mosquitto_sub
  542. \-t
  543. sensors/#
  544. \-U
  545. sensors/+/temperature
  546. \-v
  547. .RE
  548. .sp
  549. Note also that because retained messages are published by the broker on receipt of a SUBSCRIBE command, subscribing and unsubscribing to the same topic may result in messages being received at the client\&.
  550. .sp
  551. This option may be repeated to unsubscribe from multiple topics\&.
  552. .RE
  553. .PP
  554. \fB\-v\fR, \fB\-\-verbose\fR
  555. .RS 4
  556. 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"\&.
  557. .RE
  558. .PP
  559. \fB\-V\fR, \fB\-\-protocol\-version\fR
  560. .RS 4
  561. Specify which version of the MQTT protocol should be used when connecting to the remote broker\&. Can be
  562. \fB5\fR,
  563. \fB311\fR,
  564. \fB31\fR, or the more verbose
  565. \fBmqttv5\fR,
  566. \fBmqttv311\fR, or
  567. \fBmqttv31\fR\&. Defaults to
  568. \fB311\fR\&.
  569. .RE
  570. .PP
  571. \fB\-W\fR
  572. .RS 4
  573. Provide a timeout as an integer number of seconds\&. mosquitto_sub will stop processing messages and disconnect after this number of seconds has passed\&. The timeout starts just after the client has connected to the broker\&.
  574. .RE
  575. .PP
  576. \fB\-\-will\-payload\fR
  577. .RS 4
  578. 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
  579. \fB\-\-will\-topic\fR\&.
  580. .RE
  581. .PP
  582. \fB\-\-will\-qos\fR
  583. .RS 4
  584. The QoS to use for the Will\&. Defaults to 0\&. This must be used in conjunction with
  585. \fB\-\-will\-topic\fR\&.
  586. .RE
  587. .PP
  588. \fB\-\-will\-retain\fR
  589. .RS 4
  590. 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
  591. \fB\-\-will\-topic\fR\&.
  592. .RE
  593. .PP
  594. \fB\-\-will\-topic\fR
  595. .RS 4
  596. The topic on which to send a Will, in the event that the client disconnects unexpectedly\&.
  597. .RE
  598. .PP
  599. \fB\-x\fR
  600. .RS 4
  601. Set the session\-expiry\-interval property on the CONNECT packet\&. Applies to MQTT v5 clients only\&. Set to 0\-4294967294 to specify the session will expire in that many seconds after the client disconnects, or use \-1, 4294967295, or ∞ for a session that does not expire\&. Defaults to \-1 if \-c is also given, or 0 if \-c not given\&.
  602. .sp
  603. If the session is set to never expire, either with \-x or \-c, then a client id must be provided\&.
  604. .RE
  605. .SH "OUTPUT FORMAT"
  606. .PP
  607. There are three ways of formatting the output from mosquitto_sub\&. In all cases a new\-line character is appended for each message received unless the
  608. \fB\-N\fR
  609. argument is passed to mosquitto_sub\&.
  610. .PP
  611. Payload\-only is the default output format and will print the payload exactly as it is received\&.
  612. .PP
  613. Verbose mode is activated with
  614. \fB\-v\fR
  615. and prints the message topic and the payload, separated by a space\&.
  616. .PP
  617. The final option is formatted output, which allows the user to define a custom output format\&. The behaviour is controlled with the
  618. \fB\-F format\-string\fR
  619. option\&. The format string is a free text string where interpreted sequences are replaced by different parameters\&. The available interpreted sequences are described below\&.
  620. .PP
  621. Three characters are used to start an interpreted sequence:
  622. \fB%\fR,
  623. \fB@\fR
  624. and
  625. \fB\e\fR\&. Sequences starting with
  626. \fB%\fR
  627. are either parameters related to the MQTT message being printed, or are helper sequences to avoid the need to type long date format strings for example\&. Sequences starting with
  628. \fB@\fR
  629. are passed to the
  630. \fBstrftime\fR(3)
  631. function (with the @ replaced with a % \- note that only the character immediately after the @ is passed to strftime)\&. This allows the construction of a wide variety of time based outputs\&. The output options for strftime vary from platform to platform, so please check what is available for your platform\&. mosquitto_sub does provide one extension to strftime which is
  632. \fB@N\fR, which can be used to obtain the number of nanoseconds passed in the current second\&. The resolution of this option varies depending on the platform\&. The final sequence character is
  633. \fB\e\fR, which is used to input some characters that would otherwise be difficult to enter\&.
  634. .SS "Flag characters"
  635. .PP
  636. The parameters %A, %C, %E, %F, %I, %l, %m, %p, %R, %S, %t, %x, and %X can have optional flags immediately after the % character\&.
  637. .PP
  638. \fB0\fR
  639. .RS 4
  640. The value should be zero padded\&. This applies to the parameters %A, %E, %F, %l, %m, %S, %X, and %x\&. It will be ignored for other parameters\&. If used with the
  641. \fB\-\fR
  642. flag, the
  643. \fB0\fR
  644. flag will be ignored\&.
  645. .RE
  646. .PP
  647. \fB\-\fR
  648. .RS 4
  649. The value will be left aligned to the field width, padded with blanks\&. The default is right alignment, with either 0 or blank padding\&.
  650. .RE
  651. .SS "Field width"
  652. .PP
  653. Some of the MQTT related parameters can be formatted with an option to set their field width in a similar way to regular printf style formats, i\&.e\&. this sets the minimum width when printing this parameter\&. This applies to the options %A, %C, %E, %F, %I, %l, %m, %p, %R, %S, %t, %x, %X\&.
  654. .PP
  655. For example
  656. \fB%10t\fR
  657. would set the minimum topic field width to 10 characters\&.
  658. .SS "Maximum width"
  659. .PP
  660. Some of the MQTT related parameters can be formatted with an option to set a maximum field width in a similar way to regular printf style formats\&. This applies to the options %C, %I, %R, %t\&.
  661. .PP
  662. For example
  663. \fB%10\&.10t\fR
  664. would set the minimum topic field width to 10 characters, and the maximum topic width to 10 characters, i\&.e\&. the field will always be exactly 10 characters long\&.
  665. .SS "MQTT related parameters"
  666. .sp
  667. .RS 4
  668. .ie n \{\
  669. \h'-04'\(bu\h'+03'\c
  670. .\}
  671. .el \{\
  672. .sp -1
  673. .IP \(bu 2.3
  674. .\}
  675. \fB%%\fR
  676. a literal %\&.
  677. .RE
  678. .sp
  679. .RS 4
  680. .ie n \{\
  681. \h'-04'\(bu\h'+03'\c
  682. .\}
  683. .el \{\
  684. .sp -1
  685. .IP \(bu 2.3
  686. .\}
  687. \fB%A\fR
  688. the MQTT v5 topic\-alias property, if present\&.
  689. .RE
  690. .sp
  691. .RS 4
  692. .ie n \{\
  693. \h'-04'\(bu\h'+03'\c
  694. .\}
  695. .el \{\
  696. .sp -1
  697. .IP \(bu 2.3
  698. .\}
  699. \fB%C\fR
  700. the MQTT v5 content\-type property, if present\&.
  701. .RE
  702. .sp
  703. .RS 4
  704. .ie n \{\
  705. \h'-04'\(bu\h'+03'\c
  706. .\}
  707. .el \{\
  708. .sp -1
  709. .IP \(bu 2.3
  710. .\}
  711. \fB%D\fR
  712. the MQTT v5 correlation\-data property, if present\&. Note that this property is specified as binary data, so may produce non\-printable characters\&.
  713. .RE
  714. .sp
  715. .RS 4
  716. .ie n \{\
  717. \h'-04'\(bu\h'+03'\c
  718. .\}
  719. .el \{\
  720. .sp -1
  721. .IP \(bu 2.3
  722. .\}
  723. \fB%E\fR
  724. the MQTT v5 message\-expiry\-interval property, if present\&.
  725. .RE
  726. .sp
  727. .RS 4
  728. .ie n \{\
  729. \h'-04'\(bu\h'+03'\c
  730. .\}
  731. .el \{\
  732. .sp -1
  733. .IP \(bu 2.3
  734. .\}
  735. \fB%F\fR
  736. the MQTT v5 payload\-format\-indicator property, if present\&.
  737. .RE
  738. .sp
  739. .RS 4
  740. .ie n \{\
  741. \h'-04'\(bu\h'+03'\c
  742. .\}
  743. .el \{\
  744. .sp -1
  745. .IP \(bu 2.3
  746. .\}
  747. \fB%l\fR
  748. the length of the payload in bytes\&.
  749. .RE
  750. .sp
  751. .RS 4
  752. .ie n \{\
  753. \h'-04'\(bu\h'+03'\c
  754. .\}
  755. .el \{\
  756. .sp -1
  757. .IP \(bu 2.3
  758. .\}
  759. \fB%m\fR
  760. the message id (only relevant for messages with QoS>0)\&.
  761. .RE
  762. .sp
  763. .RS 4
  764. .ie n \{\
  765. \h'-04'\(bu\h'+03'\c
  766. .\}
  767. .el \{\
  768. .sp -1
  769. .IP \(bu 2.3
  770. .\}
  771. \fB%P\fR
  772. the MQTT v5 user\-property property, if present\&. This will be printed in the form key:value\&. It is possible for any number of user properties to be attached to a message, and to have duplicate keys\&.
  773. .RE
  774. .sp
  775. .RS 4
  776. .ie n \{\
  777. \h'-04'\(bu\h'+03'\c
  778. .\}
  779. .el \{\
  780. .sp -1
  781. .IP \(bu 2.3
  782. .\}
  783. \fB%p\fR
  784. the payload raw bytes (may produce non\-printable characters depending on the payload)\&.
  785. .RE
  786. .sp
  787. .RS 4
  788. .ie n \{\
  789. \h'-04'\(bu\h'+03'\c
  790. .\}
  791. .el \{\
  792. .sp -1
  793. .IP \(bu 2.3
  794. .\}
  795. \fB%q\fR
  796. the message QoS\&.
  797. .RE
  798. .sp
  799. .RS 4
  800. .ie n \{\
  801. \h'-04'\(bu\h'+03'\c
  802. .\}
  803. .el \{\
  804. .sp -1
  805. .IP \(bu 2.3
  806. .\}
  807. \fB%R\fR
  808. the MQTT v5 response\-topic property, if present\&.
  809. .RE
  810. .sp
  811. .RS 4
  812. .ie n \{\
  813. \h'-04'\(bu\h'+03'\c
  814. .\}
  815. .el \{\
  816. .sp -1
  817. .IP \(bu 2.3
  818. .\}
  819. \fB%r\fR
  820. the retained flag for the message\&.
  821. .RE
  822. .sp
  823. .RS 4
  824. .ie n \{\
  825. \h'-04'\(bu\h'+03'\c
  826. .\}
  827. .el \{\
  828. .sp -1
  829. .IP \(bu 2.3
  830. .\}
  831. \fB%S\fR
  832. the MQTT v5 subscription\-identifier property, if present\&.
  833. .RE
  834. .sp
  835. .RS 4
  836. .ie n \{\
  837. \h'-04'\(bu\h'+03'\c
  838. .\}
  839. .el \{\
  840. .sp -1
  841. .IP \(bu 2.3
  842. .\}
  843. \fB%t\fR
  844. the message topic\&.
  845. .RE
  846. .sp
  847. .RS 4
  848. .ie n \{\
  849. \h'-04'\(bu\h'+03'\c
  850. .\}
  851. .el \{\
  852. .sp -1
  853. .IP \(bu 2.3
  854. .\}
  855. \fB%x\fR
  856. the payload with each byte as a hexadecimal number (lower case)\&.
  857. .RE
  858. .sp
  859. .RS 4
  860. .ie n \{\
  861. \h'-04'\(bu\h'+03'\c
  862. .\}
  863. .el \{\
  864. .sp -1
  865. .IP \(bu 2.3
  866. .\}
  867. \fB%X\fR
  868. the payload with each byte as a hexadecimal number (upper case)\&.
  869. .RE
  870. .SS "Helpers"
  871. .sp
  872. .RS 4
  873. .ie n \{\
  874. \h'-04'\(bu\h'+03'\c
  875. .\}
  876. .el \{\
  877. .sp -1
  878. .IP \(bu 2.3
  879. .\}
  880. \fB%I\fR
  881. ISO\-8601 format date and time, e\&.g\&. 2016\-08\-10T09:47:38+0100
  882. .RE
  883. .sp
  884. .RS 4
  885. .ie n \{\
  886. \h'-04'\(bu\h'+03'\c
  887. .\}
  888. .el \{\
  889. .sp -1
  890. .IP \(bu 2.3
  891. .\}
  892. \fB%j\fR
  893. JSON output of message parameters and timestamp, with a quoted and escaped payload\&. For example
  894. {"tst":"2020\-05\-06T22:12:00\&.000000+0100","topic":"greeting","qos":0,"retain":0,"payload":"hello world"}
  895. .RE
  896. .sp
  897. .RS 4
  898. .ie n \{\
  899. \h'-04'\(bu\h'+03'\c
  900. .\}
  901. .el \{\
  902. .sp -1
  903. .IP \(bu 2.3
  904. .\}
  905. \fB%J\fR
  906. JSON output of message parameters and timestamp, with a non\-quoted and non\-escaped payload \- this means the payload must itself be valid JSON\&. For example:
  907. {"tst":"2020\-05\-06T22:12:00\&.000000+0100","topic":"foo","qos":0,"retain":0,"payload":{"temperature":27\&.0,"humidity":57}}\&.
  908. .sp
  909. If the payload is not valid JSON, then the error message "Error: Message payload is not valid JSON on topic <topic>" will be printed to stderr\&.
  910. .RE
  911. .sp
  912. .RS 4
  913. .ie n \{\
  914. \h'-04'\(bu\h'+03'\c
  915. .\}
  916. .el \{\
  917. .sp -1
  918. .IP \(bu 2.3
  919. .\}
  920. \fB%I\fR
  921. ISO\-8601 format date and time, e\&.g\&. 2016\-08\-10T09:47:38+0100
  922. .RE
  923. .sp
  924. .RS 4
  925. .ie n \{\
  926. \h'-04'\(bu\h'+03'\c
  927. .\}
  928. .el \{\
  929. .sp -1
  930. .IP \(bu 2.3
  931. .\}
  932. \fB%U\fR
  933. Unix timestamp with nanoseconds, e\&.g\&. 1470818943\&.786368637
  934. .RE
  935. .SS "Time related parameters"
  936. .sp
  937. .RS 4
  938. .ie n \{\
  939. \h'-04'\(bu\h'+03'\c
  940. .\}
  941. .el \{\
  942. .sp -1
  943. .IP \(bu 2.3
  944. .\}
  945. \fB@@\fR
  946. a literal @\&.
  947. .RE
  948. .sp
  949. .RS 4
  950. .ie n \{\
  951. \h'-04'\(bu\h'+03'\c
  952. .\}
  953. .el \{\
  954. .sp -1
  955. .IP \(bu 2.3
  956. .\}
  957. \fB@X\fR
  958. pass the character represented by
  959. \fBX\fR
  960. to the strftime function as
  961. \fB%X\fR\&. The options supported are platform dependent\&.
  962. .RE
  963. .sp
  964. .RS 4
  965. .ie n \{\
  966. \h'-04'\(bu\h'+03'\c
  967. .\}
  968. .el \{\
  969. .sp -1
  970. .IP \(bu 2.3
  971. .\}
  972. \fB@N\fR
  973. the number of nanoseconds that have passed in the current second, with varying timing resolution depending on platform\&.
  974. .RE
  975. .SS "Escape characters"
  976. .sp
  977. .RS 4
  978. .ie n \{\
  979. \h'-04'\(bu\h'+03'\c
  980. .\}
  981. .el \{\
  982. .sp -1
  983. .IP \(bu 2.3
  984. .\}
  985. \fB\e\e\fR
  986. a literal \e\&.
  987. .RE
  988. .sp
  989. .RS 4
  990. .ie n \{\
  991. \h'-04'\(bu\h'+03'\c
  992. .\}
  993. .el \{\
  994. .sp -1
  995. .IP \(bu 2.3
  996. .\}
  997. \fB\e0\fR
  998. a null character\&. Can be used to separate different parameters that may contain spaces (e\&.g\&. topic, payload) so that processing with tools such as
  999. \fBxargs\fR(1)
  1000. is easier\&.
  1001. .RE
  1002. .sp
  1003. .RS 4
  1004. .ie n \{\
  1005. \h'-04'\(bu\h'+03'\c
  1006. .\}
  1007. .el \{\
  1008. .sp -1
  1009. .IP \(bu 2.3
  1010. .\}
  1011. \fB\ea\fR
  1012. alert/bell\&.
  1013. .RE
  1014. .sp
  1015. .RS 4
  1016. .ie n \{\
  1017. \h'-04'\(bu\h'+03'\c
  1018. .\}
  1019. .el \{\
  1020. .sp -1
  1021. .IP \(bu 2.3
  1022. .\}
  1023. \fB\ee\fR
  1024. the escape sequence, which can be used with ANSI colour codes to provide coloured output for example\&.
  1025. .RE
  1026. .sp
  1027. .RS 4
  1028. .ie n \{\
  1029. \h'-04'\(bu\h'+03'\c
  1030. .\}
  1031. .el \{\
  1032. .sp -1
  1033. .IP \(bu 2.3
  1034. .\}
  1035. \fB\en\fR
  1036. end of line\&.
  1037. .RE
  1038. .sp
  1039. .RS 4
  1040. .ie n \{\
  1041. \h'-04'\(bu\h'+03'\c
  1042. .\}
  1043. .el \{\
  1044. .sp -1
  1045. .IP \(bu 2.3
  1046. .\}
  1047. \fB\er\fR
  1048. carriage return\&.
  1049. .RE
  1050. .sp
  1051. .RS 4
  1052. .ie n \{\
  1053. \h'-04'\(bu\h'+03'\c
  1054. .\}
  1055. .el \{\
  1056. .sp -1
  1057. .IP \(bu 2.3
  1058. .\}
  1059. \fB\et\fR
  1060. horizontal tab\&.
  1061. .RE
  1062. .sp
  1063. .RS 4
  1064. .ie n \{\
  1065. \h'-04'\(bu\h'+03'\c
  1066. .\}
  1067. .el \{\
  1068. .sp -1
  1069. .IP \(bu 2.3
  1070. .\}
  1071. \fB\ev\fR
  1072. vertical tab\&.
  1073. .RE
  1074. .SH "WILLS"
  1075. .PP
  1076. mosquitto_sub can register a message with the broker that will be sent out if it disconnects unexpectedly\&. See
  1077. \fBmqtt\fR(7)
  1078. for more information\&.
  1079. .PP
  1080. The minimum requirement for this is to use
  1081. \fB\-\-will\-topic\fR
  1082. to specify which topic the will should be sent out on\&. This will result in a non\-retained, zero length message with QoS 0\&.
  1083. .PP
  1084. Use the
  1085. \fB\-\-will\-retain\fR,
  1086. \fB\-\-will\-payload\fR
  1087. and
  1088. \fB\-\-will\-qos\fR
  1089. arguments to modify the other will parameters\&.
  1090. .SH "PROPERTIES"
  1091. .PP
  1092. The
  1093. \fB\-D\fR
  1094. /
  1095. \fB\-\-property\fR
  1096. option allows adding properties to different stages of the mosquitto_sub run\&. The properties supported for each command are as follows:
  1097. .SS "Connect"
  1098. .sp
  1099. .RS 4
  1100. .ie n \{\
  1101. \h'-04'\(bu\h'+03'\c
  1102. .\}
  1103. .el \{\
  1104. .sp -1
  1105. .IP \(bu 2.3
  1106. .\}
  1107. \fBauthentication\-data\fR
  1108. (binary data \- note treated as a string in mosquitto_sub)
  1109. .RE
  1110. .sp
  1111. .RS 4
  1112. .ie n \{\
  1113. \h'-04'\(bu\h'+03'\c
  1114. .\}
  1115. .el \{\
  1116. .sp -1
  1117. .IP \(bu 2.3
  1118. .\}
  1119. \fBauthentication\-method\fR
  1120. (UTF\-8 string)
  1121. .RE
  1122. .sp
  1123. .RS 4
  1124. .ie n \{\
  1125. \h'-04'\(bu\h'+03'\c
  1126. .\}
  1127. .el \{\
  1128. .sp -1
  1129. .IP \(bu 2.3
  1130. .\}
  1131. \fBmaximum\-packet\-size\fR
  1132. (32\-bit unsigned integer)
  1133. .RE
  1134. .sp
  1135. .RS 4
  1136. .ie n \{\
  1137. \h'-04'\(bu\h'+03'\c
  1138. .\}
  1139. .el \{\
  1140. .sp -1
  1141. .IP \(bu 2.3
  1142. .\}
  1143. \fBreceive\-maximum\fR
  1144. (16\-bit unsigned integer)
  1145. .RE
  1146. .sp
  1147. .RS 4
  1148. .ie n \{\
  1149. \h'-04'\(bu\h'+03'\c
  1150. .\}
  1151. .el \{\
  1152. .sp -1
  1153. .IP \(bu 2.3
  1154. .\}
  1155. \fBrequest\-problem\-information\fR
  1156. (8\-bit unsigned integer)
  1157. .RE
  1158. .sp
  1159. .RS 4
  1160. .ie n \{\
  1161. \h'-04'\(bu\h'+03'\c
  1162. .\}
  1163. .el \{\
  1164. .sp -1
  1165. .IP \(bu 2.3
  1166. .\}
  1167. \fBrequest\-response\-information\fR
  1168. (8\-bit unsigned integer)
  1169. .RE
  1170. .sp
  1171. .RS 4
  1172. .ie n \{\
  1173. \h'-04'\(bu\h'+03'\c
  1174. .\}
  1175. .el \{\
  1176. .sp -1
  1177. .IP \(bu 2.3
  1178. .\}
  1179. \fBsession\-expiry\-interval\fR
  1180. (32\-bit unsigned integer, note use
  1181. \fB\-x\fR
  1182. instead)
  1183. .RE
  1184. .sp
  1185. .RS 4
  1186. .ie n \{\
  1187. \h'-04'\(bu\h'+03'\c
  1188. .\}
  1189. .el \{\
  1190. .sp -1
  1191. .IP \(bu 2.3
  1192. .\}
  1193. \fBtopic\-alias\-maximum\fR
  1194. (16\-bit unsigned integer)
  1195. .RE
  1196. .sp
  1197. .RS 4
  1198. .ie n \{\
  1199. \h'-04'\(bu\h'+03'\c
  1200. .\}
  1201. .el \{\
  1202. .sp -1
  1203. .IP \(bu 2.3
  1204. .\}
  1205. \fBuser\-property\fR
  1206. (UTF\-8 string pair)
  1207. .RE
  1208. .SS "Subscribe"
  1209. .sp
  1210. .RS 4
  1211. .ie n \{\
  1212. \h'-04'\(bu\h'+03'\c
  1213. .\}
  1214. .el \{\
  1215. .sp -1
  1216. .IP \(bu 2.3
  1217. .\}
  1218. \fBuser\-property\fR
  1219. (UTF\-8 string pair)
  1220. .RE
  1221. .SS "Unsubscribe"
  1222. .sp
  1223. .RS 4
  1224. .ie n \{\
  1225. \h'-04'\(bu\h'+03'\c
  1226. .\}
  1227. .el \{\
  1228. .sp -1
  1229. .IP \(bu 2.3
  1230. .\}
  1231. \fBuser\-property\fR
  1232. (UTF\-8 string pair)
  1233. .RE
  1234. .SS "Disconnect"
  1235. .sp
  1236. .RS 4
  1237. .ie n \{\
  1238. \h'-04'\(bu\h'+03'\c
  1239. .\}
  1240. .el \{\
  1241. .sp -1
  1242. .IP \(bu 2.3
  1243. .\}
  1244. \fBsession\-expiry\-interval\fR
  1245. (32\-bit unsigned integer)
  1246. .RE
  1247. .sp
  1248. .RS 4
  1249. .ie n \{\
  1250. \h'-04'\(bu\h'+03'\c
  1251. .\}
  1252. .el \{\
  1253. .sp -1
  1254. .IP \(bu 2.3
  1255. .\}
  1256. \fBuser\-property\fR
  1257. (UTF\-8 string pair)
  1258. .RE
  1259. .SS "Will properties"
  1260. .sp
  1261. .RS 4
  1262. .ie n \{\
  1263. \h'-04'\(bu\h'+03'\c
  1264. .\}
  1265. .el \{\
  1266. .sp -1
  1267. .IP \(bu 2.3
  1268. .\}
  1269. \fBcontent\-type\fR
  1270. (UTF\-8 string)
  1271. .RE
  1272. .sp
  1273. .RS 4
  1274. .ie n \{\
  1275. \h'-04'\(bu\h'+03'\c
  1276. .\}
  1277. .el \{\
  1278. .sp -1
  1279. .IP \(bu 2.3
  1280. .\}
  1281. \fBcorrelation\-data\fR
  1282. (binary data \- note treated as a string in mosquitto_sub)
  1283. .RE
  1284. .sp
  1285. .RS 4
  1286. .ie n \{\
  1287. \h'-04'\(bu\h'+03'\c
  1288. .\}
  1289. .el \{\
  1290. .sp -1
  1291. .IP \(bu 2.3
  1292. .\}
  1293. \fBmessage\-expiry\-interval\fR
  1294. (32\-bit unsigned integer)
  1295. .RE
  1296. .sp
  1297. .RS 4
  1298. .ie n \{\
  1299. \h'-04'\(bu\h'+03'\c
  1300. .\}
  1301. .el \{\
  1302. .sp -1
  1303. .IP \(bu 2.3
  1304. .\}
  1305. \fBpayload\-format\-indicator\fR
  1306. (8\-bit unsigned integer)
  1307. .RE
  1308. .sp
  1309. .RS 4
  1310. .ie n \{\
  1311. \h'-04'\(bu\h'+03'\c
  1312. .\}
  1313. .el \{\
  1314. .sp -1
  1315. .IP \(bu 2.3
  1316. .\}
  1317. \fBresponse\-topic\fR
  1318. (UTF\-8 string)
  1319. .RE
  1320. .sp
  1321. .RS 4
  1322. .ie n \{\
  1323. \h'-04'\(bu\h'+03'\c
  1324. .\}
  1325. .el \{\
  1326. .sp -1
  1327. .IP \(bu 2.3
  1328. .\}
  1329. \fBuser\-property\fR
  1330. (UTF\-8 string pair)
  1331. .RE
  1332. .sp
  1333. .RS 4
  1334. .ie n \{\
  1335. \h'-04'\(bu\h'+03'\c
  1336. .\}
  1337. .el \{\
  1338. .sp -1
  1339. .IP \(bu 2.3
  1340. .\}
  1341. \fBwill\-delay\-interval\fR
  1342. (32\-bit unsigned integer)
  1343. .RE
  1344. .SH "EXIT STATUS"
  1345. .PP
  1346. mosquitto_sub returns zero on success, or non\-zero on error\&. If the connection is refused by the broker at the MQTT level, then the exit code is the CONNACK reason code\&. If another error occurs, the exit code is a libmosquitto return value\&.
  1347. .PP
  1348. MQTT v3\&.1\&.1 CONNACK codes:
  1349. .sp
  1350. .RS 4
  1351. .ie n \{\
  1352. \h'-04'\(bu\h'+03'\c
  1353. .\}
  1354. .el \{\
  1355. .sp -1
  1356. .IP \(bu 2.3
  1357. .\}
  1358. \fB0\fR
  1359. Success
  1360. .RE
  1361. .sp
  1362. .RS 4
  1363. .ie n \{\
  1364. \h'-04'\(bu\h'+03'\c
  1365. .\}
  1366. .el \{\
  1367. .sp -1
  1368. .IP \(bu 2.3
  1369. .\}
  1370. \fB1\fR
  1371. Connection refused: Bad protocol version
  1372. .RE
  1373. .sp
  1374. .RS 4
  1375. .ie n \{\
  1376. \h'-04'\(bu\h'+03'\c
  1377. .\}
  1378. .el \{\
  1379. .sp -1
  1380. .IP \(bu 2.3
  1381. .\}
  1382. \fB2\fR
  1383. Connection refused: Identifier rejected
  1384. .RE
  1385. .sp
  1386. .RS 4
  1387. .ie n \{\
  1388. \h'-04'\(bu\h'+03'\c
  1389. .\}
  1390. .el \{\
  1391. .sp -1
  1392. .IP \(bu 2.3
  1393. .\}
  1394. \fB3\fR
  1395. Connection refused: Server unavailable
  1396. .RE
  1397. .sp
  1398. .RS 4
  1399. .ie n \{\
  1400. \h'-04'\(bu\h'+03'\c
  1401. .\}
  1402. .el \{\
  1403. .sp -1
  1404. .IP \(bu 2.3
  1405. .\}
  1406. \fB4\fR
  1407. Connection refused: Bad username/password
  1408. .RE
  1409. .sp
  1410. .RS 4
  1411. .ie n \{\
  1412. \h'-04'\(bu\h'+03'\c
  1413. .\}
  1414. .el \{\
  1415. .sp -1
  1416. .IP \(bu 2.3
  1417. .\}
  1418. \fB5\fR
  1419. Connection refused: Not authorized
  1420. .RE
  1421. .PP
  1422. MQTT v5 CONNACK codes:
  1423. .sp
  1424. .RS 4
  1425. .ie n \{\
  1426. \h'-04'\(bu\h'+03'\c
  1427. .\}
  1428. .el \{\
  1429. .sp -1
  1430. .IP \(bu 2.3
  1431. .\}
  1432. \fB0\fR
  1433. Success
  1434. .RE
  1435. .sp
  1436. .RS 4
  1437. .ie n \{\
  1438. \h'-04'\(bu\h'+03'\c
  1439. .\}
  1440. .el \{\
  1441. .sp -1
  1442. .IP \(bu 2.3
  1443. .\}
  1444. \fB128\fR
  1445. Unspecified error
  1446. .RE
  1447. .sp
  1448. .RS 4
  1449. .ie n \{\
  1450. \h'-04'\(bu\h'+03'\c
  1451. .\}
  1452. .el \{\
  1453. .sp -1
  1454. .IP \(bu 2.3
  1455. .\}
  1456. \fB129\fR
  1457. Malformed packet
  1458. .RE
  1459. .sp
  1460. .RS 4
  1461. .ie n \{\
  1462. \h'-04'\(bu\h'+03'\c
  1463. .\}
  1464. .el \{\
  1465. .sp -1
  1466. .IP \(bu 2.3
  1467. .\}
  1468. \fB130\fR
  1469. Protocol error
  1470. .RE
  1471. .sp
  1472. .RS 4
  1473. .ie n \{\
  1474. \h'-04'\(bu\h'+03'\c
  1475. .\}
  1476. .el \{\
  1477. .sp -1
  1478. .IP \(bu 2.3
  1479. .\}
  1480. \fB131\fR
  1481. Implementation specific error
  1482. .RE
  1483. .sp
  1484. .RS 4
  1485. .ie n \{\
  1486. \h'-04'\(bu\h'+03'\c
  1487. .\}
  1488. .el \{\
  1489. .sp -1
  1490. .IP \(bu 2.3
  1491. .\}
  1492. \fB132\fR
  1493. Unsupported protocol version
  1494. .RE
  1495. .sp
  1496. .RS 4
  1497. .ie n \{\
  1498. \h'-04'\(bu\h'+03'\c
  1499. .\}
  1500. .el \{\
  1501. .sp -1
  1502. .IP \(bu 2.3
  1503. .\}
  1504. \fB133\fR
  1505. Client ID not valid
  1506. .RE
  1507. .sp
  1508. .RS 4
  1509. .ie n \{\
  1510. \h'-04'\(bu\h'+03'\c
  1511. .\}
  1512. .el \{\
  1513. .sp -1
  1514. .IP \(bu 2.3
  1515. .\}
  1516. \fB134\fR
  1517. Bad username or password
  1518. .RE
  1519. .sp
  1520. .RS 4
  1521. .ie n \{\
  1522. \h'-04'\(bu\h'+03'\c
  1523. .\}
  1524. .el \{\
  1525. .sp -1
  1526. .IP \(bu 2.3
  1527. .\}
  1528. \fB135\fR
  1529. Not authorized
  1530. .RE
  1531. .sp
  1532. .RS 4
  1533. .ie n \{\
  1534. \h'-04'\(bu\h'+03'\c
  1535. .\}
  1536. .el \{\
  1537. .sp -1
  1538. .IP \(bu 2.3
  1539. .\}
  1540. \fB136\fR
  1541. Server unavailable
  1542. .RE
  1543. .sp
  1544. .RS 4
  1545. .ie n \{\
  1546. \h'-04'\(bu\h'+03'\c
  1547. .\}
  1548. .el \{\
  1549. .sp -1
  1550. .IP \(bu 2.3
  1551. .\}
  1552. \fB137\fR
  1553. Server busy
  1554. .RE
  1555. .sp
  1556. .RS 4
  1557. .ie n \{\
  1558. \h'-04'\(bu\h'+03'\c
  1559. .\}
  1560. .el \{\
  1561. .sp -1
  1562. .IP \(bu 2.3
  1563. .\}
  1564. \fB138\fR
  1565. Banned
  1566. .RE
  1567. .sp
  1568. .RS 4
  1569. .ie n \{\
  1570. \h'-04'\(bu\h'+03'\c
  1571. .\}
  1572. .el \{\
  1573. .sp -1
  1574. .IP \(bu 2.3
  1575. .\}
  1576. \fB139\fR
  1577. Server shutting down
  1578. .RE
  1579. .sp
  1580. .RS 4
  1581. .ie n \{\
  1582. \h'-04'\(bu\h'+03'\c
  1583. .\}
  1584. .el \{\
  1585. .sp -1
  1586. .IP \(bu 2.3
  1587. .\}
  1588. \fB140\fR
  1589. Bad authentication method
  1590. .RE
  1591. .sp
  1592. .RS 4
  1593. .ie n \{\
  1594. \h'-04'\(bu\h'+03'\c
  1595. .\}
  1596. .el \{\
  1597. .sp -1
  1598. .IP \(bu 2.3
  1599. .\}
  1600. \fB141\fR
  1601. Keep alive timeout
  1602. .RE
  1603. .sp
  1604. .RS 4
  1605. .ie n \{\
  1606. \h'-04'\(bu\h'+03'\c
  1607. .\}
  1608. .el \{\
  1609. .sp -1
  1610. .IP \(bu 2.3
  1611. .\}
  1612. \fB142\fR
  1613. Session taken over
  1614. .RE
  1615. .sp
  1616. .RS 4
  1617. .ie n \{\
  1618. \h'-04'\(bu\h'+03'\c
  1619. .\}
  1620. .el \{\
  1621. .sp -1
  1622. .IP \(bu 2.3
  1623. .\}
  1624. \fB143\fR
  1625. Topic filter invalid
  1626. .RE
  1627. .sp
  1628. .RS 4
  1629. .ie n \{\
  1630. \h'-04'\(bu\h'+03'\c
  1631. .\}
  1632. .el \{\
  1633. .sp -1
  1634. .IP \(bu 2.3
  1635. .\}
  1636. \fB144\fR
  1637. Topic name invalid
  1638. .RE
  1639. .sp
  1640. .RS 4
  1641. .ie n \{\
  1642. \h'-04'\(bu\h'+03'\c
  1643. .\}
  1644. .el \{\
  1645. .sp -1
  1646. .IP \(bu 2.3
  1647. .\}
  1648. \fB147\fR
  1649. Receive maximum exceeded
  1650. .RE
  1651. .sp
  1652. .RS 4
  1653. .ie n \{\
  1654. \h'-04'\(bu\h'+03'\c
  1655. .\}
  1656. .el \{\
  1657. .sp -1
  1658. .IP \(bu 2.3
  1659. .\}
  1660. \fB148\fR
  1661. Topic alias invalid
  1662. .RE
  1663. .sp
  1664. .RS 4
  1665. .ie n \{\
  1666. \h'-04'\(bu\h'+03'\c
  1667. .\}
  1668. .el \{\
  1669. .sp -1
  1670. .IP \(bu 2.3
  1671. .\}
  1672. \fB149\fR
  1673. Packet too large
  1674. .RE
  1675. .sp
  1676. .RS 4
  1677. .ie n \{\
  1678. \h'-04'\(bu\h'+03'\c
  1679. .\}
  1680. .el \{\
  1681. .sp -1
  1682. .IP \(bu 2.3
  1683. .\}
  1684. \fB148\fR
  1685. Message rate too high
  1686. .RE
  1687. .sp
  1688. .RS 4
  1689. .ie n \{\
  1690. \h'-04'\(bu\h'+03'\c
  1691. .\}
  1692. .el \{\
  1693. .sp -1
  1694. .IP \(bu 2.3
  1695. .\}
  1696. \fB151\fR
  1697. Quota exceeded
  1698. .RE
  1699. .sp
  1700. .RS 4
  1701. .ie n \{\
  1702. \h'-04'\(bu\h'+03'\c
  1703. .\}
  1704. .el \{\
  1705. .sp -1
  1706. .IP \(bu 2.3
  1707. .\}
  1708. \fB152\fR
  1709. Administrative action
  1710. .RE
  1711. .sp
  1712. .RS 4
  1713. .ie n \{\
  1714. \h'-04'\(bu\h'+03'\c
  1715. .\}
  1716. .el \{\
  1717. .sp -1
  1718. .IP \(bu 2.3
  1719. .\}
  1720. \fB153\fR
  1721. Payload format invalid
  1722. .RE
  1723. .sp
  1724. .RS 4
  1725. .ie n \{\
  1726. \h'-04'\(bu\h'+03'\c
  1727. .\}
  1728. .el \{\
  1729. .sp -1
  1730. .IP \(bu 2.3
  1731. .\}
  1732. \fB154\fR
  1733. Retain not supported
  1734. .RE
  1735. .sp
  1736. .RS 4
  1737. .ie n \{\
  1738. \h'-04'\(bu\h'+03'\c
  1739. .\}
  1740. .el \{\
  1741. .sp -1
  1742. .IP \(bu 2.3
  1743. .\}
  1744. \fB155\fR
  1745. QoS not supported
  1746. .RE
  1747. .sp
  1748. .RS 4
  1749. .ie n \{\
  1750. \h'-04'\(bu\h'+03'\c
  1751. .\}
  1752. .el \{\
  1753. .sp -1
  1754. .IP \(bu 2.3
  1755. .\}
  1756. \fB156\fR
  1757. Use another server
  1758. .RE
  1759. .sp
  1760. .RS 4
  1761. .ie n \{\
  1762. \h'-04'\(bu\h'+03'\c
  1763. .\}
  1764. .el \{\
  1765. .sp -1
  1766. .IP \(bu 2.3
  1767. .\}
  1768. \fB157\fR
  1769. Server moved
  1770. .RE
  1771. .sp
  1772. .RS 4
  1773. .ie n \{\
  1774. \h'-04'\(bu\h'+03'\c
  1775. .\}
  1776. .el \{\
  1777. .sp -1
  1778. .IP \(bu 2.3
  1779. .\}
  1780. \fB158\fR
  1781. Shared subscriptions not supported
  1782. .RE
  1783. .sp
  1784. .RS 4
  1785. .ie n \{\
  1786. \h'-04'\(bu\h'+03'\c
  1787. .\}
  1788. .el \{\
  1789. .sp -1
  1790. .IP \(bu 2.3
  1791. .\}
  1792. \fB159\fR
  1793. Connection rate exceeded
  1794. .RE
  1795. .sp
  1796. .RS 4
  1797. .ie n \{\
  1798. \h'-04'\(bu\h'+03'\c
  1799. .\}
  1800. .el \{\
  1801. .sp -1
  1802. .IP \(bu 2.3
  1803. .\}
  1804. \fB160\fR
  1805. Maximum connect time
  1806. .RE
  1807. .sp
  1808. .RS 4
  1809. .ie n \{\
  1810. \h'-04'\(bu\h'+03'\c
  1811. .\}
  1812. .el \{\
  1813. .sp -1
  1814. .IP \(bu 2.3
  1815. .\}
  1816. \fB161\fR
  1817. Subscription IDs not supported
  1818. .RE
  1819. .sp
  1820. .RS 4
  1821. .ie n \{\
  1822. \h'-04'\(bu\h'+03'\c
  1823. .\}
  1824. .el \{\
  1825. .sp -1
  1826. .IP \(bu 2.3
  1827. .\}
  1828. \fB162\fR
  1829. Wildcard subscriptions not supported
  1830. .RE
  1831. .SH "EXAMPLES"
  1832. .PP
  1833. 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\&.
  1834. .PP
  1835. Subscribe to temperature information on localhost with QoS 1:
  1836. .sp
  1837. .RS 4
  1838. .ie n \{\
  1839. \h'-04'\(bu\h'+03'\c
  1840. .\}
  1841. .el \{\
  1842. .sp -1
  1843. .IP \(bu 2.3
  1844. .\}
  1845. mosquitto_sub
  1846. \-t
  1847. sensors/temperature
  1848. \-q
  1849. 1
  1850. .RE
  1851. .PP
  1852. 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\&.
  1853. .sp
  1854. .RS 4
  1855. .ie n \{\
  1856. \h'-04'\(bu\h'+03'\c
  1857. .\}
  1858. .el \{\
  1859. .sp -1
  1860. .IP \(bu 2.3
  1861. .\}
  1862. mosquitto_sub
  1863. \-t
  1864. sensors/machines/+/temperature/+
  1865. .RE
  1866. .PP
  1867. Subscribe to all broker status messages:
  1868. .sp
  1869. .RS 4
  1870. .ie n \{\
  1871. \h'-04'\(bu\h'+03'\c
  1872. .\}
  1873. .el \{\
  1874. .sp -1
  1875. .IP \(bu 2.3
  1876. .\}
  1877. mosquitto_sub
  1878. \-v
  1879. \-t
  1880. \e$SYS/#
  1881. .RE
  1882. .PP
  1883. Specify the output format as "ISO\-8601 date : topic : payload in hex"
  1884. .sp
  1885. .RS 4
  1886. .ie n \{\
  1887. \h'-04'\(bu\h'+03'\c
  1888. .\}
  1889. .el \{\
  1890. .sp -1
  1891. .IP \(bu 2.3
  1892. .\}
  1893. mosquitto_sub
  1894. \-F \*(Aq@Y\-@m\-@dT@H:@M:@S@z : %t : %x\*(Aq
  1895. \-t
  1896. \*(Aq#\*(Aq
  1897. .RE
  1898. .PP
  1899. Specify the output format as "seconds since epoch\&.nanoseconds : retained flag : qos : mid : payload length"
  1900. .sp
  1901. .RS 4
  1902. .ie n \{\
  1903. \h'-04'\(bu\h'+03'\c
  1904. .\}
  1905. .el \{\
  1906. .sp -1
  1907. .IP \(bu 2.3
  1908. .\}
  1909. mosquitto_sub
  1910. \-F \*(Aq%@s\&.@N : %r : %q : %m : %l\*(Aq
  1911. \-q 2
  1912. \-t
  1913. \*(Aq#\*(Aq
  1914. .RE
  1915. .PP
  1916. Topic and payload output, but with colour where supported\&.
  1917. .sp
  1918. .RS 4
  1919. .ie n \{\
  1920. \h'-04'\(bu\h'+03'\c
  1921. .\}
  1922. .el \{\
  1923. .sp -1
  1924. .IP \(bu 2.3
  1925. .\}
  1926. mosquitto_sub
  1927. \-F \*(Aq\ee[92m%t \ee[96m%p\ee[0m\*(Aq
  1928. \-q 2
  1929. \-t
  1930. \*(Aq#\*(Aq
  1931. .RE
  1932. .SH "EXIT VALUES"
  1933. .PP
  1934. \fB0\fR
  1935. .RS 4
  1936. Success
  1937. .RE
  1938. .PP
  1939. \fB27\fR
  1940. .RS 4
  1941. Timed out waiting for message
  1942. .RE
  1943. .PP
  1944. \fBOther non\-zero value\fR
  1945. .RS 4
  1946. Unspecified failure
  1947. .RE
  1948. .SH "FILES"
  1949. .PP
  1950. $XDG_CONFIG_HOME/mosquitto_sub, $HOME/\&.config/mosquitto_sub
  1951. .RS 4
  1952. Configuration file for default options\&.
  1953. .RE
  1954. .SH "BUGS"
  1955. .PP
  1956. \fBmosquitto\fR
  1957. bug information can be found at
  1958. \m[blue]\fB\%https://github.com/eclipse/mosquitto/issues\fR\m[]
  1959. .SH "SEE ALSO"
  1960. \fBmqtt\fR(7), \fBmosquitto_pub\fR(1), \fBmosquitto_rr\fR(1), \fBmosquitto\fR(8), \fBlibmosquitto\fR(3), \fBmosquitto-tls\fR(7)
  1961. .SH "AUTHOR"
  1962. .PP
  1963. Roger Light
  1964. <roger@atchoo\&.org>