mosquitto_pub.1 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399
  1. '\" t
  2. .\" Title: mosquitto_pub
  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_PUB" "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_pub \- an MQTT version 5/3\&.1\&.1/3\&.1 client for publishing simple messages
  32. .SH "SYNOPSIS"
  33. .HP \w'\fBmosquitto_pub\fR\ 'u
  34. \fBmosquitto_pub\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\-A\fR\ \fIbind\-address\fR] [\fB\-c\fR] [\fB\-d\fR] [\fB\-D\fR\ \fIcommand\fR\ \fIidentifier\fR\ \fIvalue\fR] [\fB\-i\fR\ \fIclient\-id\fR] [\fB\-I\fR\ \fIclient\-id\-prefix\fR] [\fB\-k\fR\ \fIkeepalive\-time\fR] [\fB\-\-nodelay\fR] [\fB\-q\fR\ \fImessage\-QoS\fR] [\fB\-\-quiet\fR] [\fB\-r\fR] [\fB\-\-repeat\fR\ \fIcount\fR] [\fB\-\-repeat\-delay\fR\ \fIseconds\fR] [\fB\-S\fR] [\fB\-V\fR\ \fIprotocol\-version\fR] [\fB\-x\fR\ \fIsession\-expiry\-interval\fR] {\fB\-f\fR\ \fIfile\fR | \fB\-l\fR | \fB\-m\fR\ \fImessage\fR | \fB\-n\fR | \fB\-s\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\-\-ciphers\fR\ \fIciphers\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\-\-ciphers\fR\ \fIciphers\fR]\ [\fB\-\-tls\-version\fR\ \fIversion\fR]]] [\fB\-\-proxy\fR\ \fIsocks\-url\fR]
  35. .HP \w'\fBmosquitto_pub\fR\ 'u
  36. \fBmosquitto_pub\fR [\fB\-\-help\fR]
  37. .SH "DESCRIPTION"
  38. .PP
  39. \fBmosquitto_pub\fR
  40. is a simple MQTT version 5/3\&.1\&.1 client that will publish a single message on a topic and exit\&.
  41. .SH "ENCRYPTED CONNECTIONS"
  42. .PP
  43. \fBmosquitto_pub\fR
  44. supports TLS encrypted connections\&. It is strongly recommended that you use an encrypted connection for anything more than the most basic setup\&.
  45. .PP
  46. To enable TLS connections when using x509 certificates, one of either
  47. \fB\-\-cafile\fR
  48. or
  49. \fB\-\-capath\fR
  50. can be provided as an option\&.
  51. .PP
  52. Alternatively, if the
  53. \fB\-p 8883\fR
  54. option is used then the OS provided certificates will be loaded and neither
  55. \fB\-\-cafile\fR
  56. or
  57. \fB\-\-capath\fR
  58. are needed
  59. .PP
  60. To enable TLS connections when using TLS\-PSK, you must use the
  61. \fB\-\-psk\fR
  62. and the
  63. \fB\-\-psk\-identity\fR
  64. options\&.
  65. .SH "OPTIONS"
  66. .PP
  67. The options below may be given on the command line, but may also be placed in a config file located at
  68. \fB$XDG_CONFIG_HOME/mosquitto_pub\fR
  69. or
  70. \fB$HOME/\&.config/mosquitto_pub\fR
  71. with one pair of
  72. \fB\-option \fR\fB\fIvalue\fR\fR
  73. 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 the message type options, of which only one can be specified\&. Note also that currently some options cannot be negated, e\&.g\&.
  74. \fB\-S\fR\&. Config file lines that have a
  75. \fB#\fR
  76. as the first character are treated as comments and not processed any further\&.
  77. .PP
  78. \fB\-A\fR
  79. .RS 4
  80. Bind the outgoing connection to a local ip address/hostname\&. Use this argument if you need to restrict network communication to a particular interface\&.
  81. .RE
  82. .PP
  83. \fB\-c\fR, \fB\-\-disable\-clean\-session\fR
  84. .RS 4
  85. 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
  86. \fB\-x\fR
  87. argument\&.
  88. .sp
  89. 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\&.
  90. .sp
  91. If using this option, the client id must be set manually with
  92. \fB\-\-id\fR
  93. .RE
  94. .PP
  95. \fB\-\-cafile\fR
  96. .RS 4
  97. Define the path to a file containing PEM encoded CA certificates that are trusted\&. Used to enable SSL communication\&.
  98. .sp
  99. See also
  100. \fB\-\-capath\fR
  101. .RE
  102. .PP
  103. \fB\-\-capath\fR
  104. .RS 4
  105. Define the path to a directory containing PEM encoded CA certificates that are trusted\&. Used to enable SSL communication\&.
  106. .sp
  107. For
  108. \fB\-\-capath\fR
  109. 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\&.
  110. .sp
  111. See also
  112. \fB\-\-cafile\fR
  113. .RE
  114. .PP
  115. \fB\-\-cert\fR
  116. .RS 4
  117. Define the path to a file containing a PEM encoded certificate for this client, if required by the server\&.
  118. .sp
  119. See also
  120. \fB\-\-key\fR\&.
  121. .RE
  122. .PP
  123. \fB\-\-ciphers\fR
  124. .RS 4
  125. An openssl compatible list of TLS ciphers to support in the client\&. See
  126. \fBciphers\fR(1)
  127. for more information\&.
  128. .RE
  129. .PP
  130. \fB\-d\fR, \fB\-\-debug\fR
  131. .RS 4
  132. Enable debug messages\&.
  133. .RE
  134. .PP
  135. \fB\-D\fR, \fB\-\-property\fR
  136. .RS 4
  137. 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:
  138. .sp
  139. \fB\-D command identifier value\fR
  140. .sp
  141. \fB\-D command identifier name value\fR
  142. .sp
  143. \fBcommand\fR
  144. is the MQTT command/packet identifier and can be one of CONNECT, PUBLISH, PUBREL, DISCONNECT, AUTH, or WILL\&. The properties available for each command are listed in the
  145. Properties
  146. section\&.
  147. .sp
  148. \fBidentifier\fR
  149. 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:
  150. \fBpayload\-format\-indicator\fR\&. More details are in the
  151. Properties
  152. section\&.
  153. .sp
  154. \fBvalue\fR
  155. is the value of the property to add, with a data type that is property specific\&.
  156. .sp
  157. \fBname\fR
  158. is only used for the
  159. \fBuser\-property\fR
  160. property as the first of the two strings in the string pair\&. In that case,
  161. \fBvalue\fR
  162. is the second of the strings in the pair\&.
  163. .RE
  164. .PP
  165. \fB\-f\fR, \fB\-\-file\fR
  166. .RS 4
  167. Send the contents of a file as the message\&.
  168. .RE
  169. .PP
  170. \fB\-\-help\fR
  171. .RS 4
  172. Display usage information\&.
  173. .RE
  174. .PP
  175. \fB\-h\fR, \fB\-\-host\fR
  176. .RS 4
  177. Specify the host to connect to\&. Defaults to localhost\&.
  178. .RE
  179. .PP
  180. \fB\-i\fR, \fB\-\-id\fR
  181. .RS 4
  182. 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
  183. \fBmosq\-XXXXXXXXXXXXXXXXXX\fR, where the
  184. \fBX\fR
  185. 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\&.
  186. .sp
  187. This option cannot be used at the same time as the
  188. \fB\-\-id\-prefix\fR
  189. argument\&.
  190. .RE
  191. .PP
  192. \fB\-I\fR, \fB\-\-id\-prefix\fR
  193. .RS 4
  194. 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
  195. \fB\-\-id\fR
  196. argument\&.
  197. .RE
  198. .PP
  199. \fB\-\-insecure\fR
  200. .RS 4
  201. 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
  202. \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\&.
  203. .RE
  204. .PP
  205. \fB\-k\fR, \fB\-\-keepalive\fR
  206. .RS 4
  207. 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\&.
  208. .RE
  209. .PP
  210. \fB\-\-key\fR
  211. .RS 4
  212. Define the path to a file containing a PEM encoded private key for this client, if required by the server\&.
  213. .sp
  214. See also
  215. \fB\-\-cert\fR\&.
  216. .RE
  217. .PP
  218. \fB\-\-keyform\fR
  219. .RS 4
  220. 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\&.
  221. .sp
  222. See also
  223. \fB\-\-tls\-engine\fR\&.
  224. .RE
  225. .PP
  226. \fB\-L\fR, \fB\-\-url\fR
  227. .RS 4
  228. 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
  229. .sp
  230. If the scheme is mqtt:// then the port defaults to 1883\&. If the scheme is mqtts:// then the port defaults to 8883\&.
  231. .RE
  232. .PP
  233. \fB\-l\fR, \fB\-\-stdin\-line\fR
  234. .RS 4
  235. Send messages read from stdin, splitting separate lines into separate messages\&.
  236. .RE
  237. .PP
  238. \fB\-m\fR, \fB\-\-message\fR
  239. .RS 4
  240. Send a single message from the command line\&.
  241. .RE
  242. .PP
  243. \fB\-n\fR, \fB\-\-null\-message\fR
  244. .RS 4
  245. Send a null (zero length) message\&.
  246. .RE
  247. .PP
  248. \fB\-\-nodelay\fR
  249. .RS 4
  250. 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\&.
  251. .RE
  252. .PP
  253. \fB\-p\fR, \fB\-\-port\fR
  254. .RS 4
  255. Connect to the port specified\&. If not given, the default of 1883 for plain MQTT or 8883 for MQTT over TLS will be used\&.
  256. .RE
  257. .PP
  258. \fB\-P\fR, \fB\-\-pw\fR
  259. .RS 4
  260. 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
  261. \fB\-\-username\fR
  262. option\&.
  263. .RE
  264. .PP
  265. \fB\-\-proxy\fR
  266. .RS 4
  267. Specify a SOCKS5 proxy to connect through\&. "None" and "username" authentication types are supported\&. The
  268. \fBsocks\-url\fR
  269. must be of the form
  270. \fBsocks5h://[username[:password]@]host[:port]\fR\&. The protocol prefix
  271. \fBsocks5h\fR
  272. 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\&.
  273. .sp
  274. If username is not given, then no authentication is attempted\&. If the port is not given, then the default of 1080 is used\&.
  275. .sp
  276. More SOCKS versions may be available in the future, depending on demand, and will use different protocol prefixes as described in
  277. \fBcurl\fR(1)\&.
  278. .RE
  279. .PP
  280. \fB\-\-psk\fR
  281. .RS 4
  282. Provide the hexadecimal (no leading 0x) pre\-shared\-key matching the one used on the broker to use TLS\-PSK encryption support\&.
  283. \fB\-\-psk\-identity\fR
  284. must also be provided to enable TLS\-PSK\&.
  285. .RE
  286. .PP
  287. \fB\-\-psk\-identity\fR
  288. .RS 4
  289. 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\&.
  290. .RE
  291. .PP
  292. \fB\-q\fR, \fB\-\-qos\fR
  293. .RS 4
  294. Specify the quality of service to use for the message, from 0, 1 and 2\&. Defaults to 0\&.
  295. .RE
  296. .PP
  297. \fB\-\-quiet\fR
  298. .RS 4
  299. 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
  300. \fB\-\-port\fR
  301. without a port)\&.
  302. .RE
  303. .PP
  304. \fB\-r\fR, \fB\-\-retain\fR
  305. .RS 4
  306. If retain is given, the message will be retained as a "last known good" value on the broker\&. See
  307. \fBmqtt\fR(7)
  308. for more information\&. Note that zero length payloads are never retained\&. If you send a zero length payload retained message it will clear any retained message on the topic\&.
  309. .RE
  310. .PP
  311. \fB\-\-repeat\fR
  312. .RS 4
  313. If the publish mode is\fB\-m\fR,
  314. \fB\-f\fR, or
  315. \fB\-s\fR
  316. (i\&.e\&. the modes where only a single message is sent), then
  317. \fB\-\-repeat\fR
  318. can be used to specify that the message will be published multiple times\&.
  319. .sp
  320. See also
  321. \fB\-\-repeat\-delay\fR\&.
  322. .RE
  323. .PP
  324. \fB\-\-repeat\-delay\fR
  325. .RS 4
  326. If using
  327. \fB\-\-repeat\fR, then the default behaviour is to publish repeated messages as soon as the previous message is delivered\&. Use
  328. \fB\-\-repeat\-delay\fR
  329. to specify the number of seconds to wait after the previous message was delivered before publishing the next\&. Does not need to be an integer number of seconds\&.
  330. .sp
  331. Note that there is no guarantee as to the actual interval between messages, this option simply defines the minimum time from delivery of one message to the start of the publish of the next\&.
  332. .RE
  333. .PP
  334. \fB\-s\fR, \fB\-\-stdin\-file\fR
  335. .RS 4
  336. Send a message read from stdin, sending the entire content as a single message\&.
  337. .RE
  338. .PP
  339. \fB\-S\fR
  340. .RS 4
  341. Use SRV lookups to determine which host to connect to\&. Performs lookups to
  342. \fB_mqtt\&._tcp\&.<host>\fR
  343. when used in conjunction with
  344. \fB\-h\fR, otherwise uses
  345. \fB_mqtt\&._tcp\&.<local dns domain>\fR\&.
  346. .RE
  347. .PP
  348. \fB\-t\fR, \fB\-\-topic\fR
  349. .RS 4
  350. The MQTT topic on which to publish the message\&. See
  351. \fBmqtt\fR(7)
  352. for more information on MQTT topics\&.
  353. .RE
  354. .PP
  355. \fB\-\-tls\-alpn\fR
  356. .RS 4
  357. Provide a protocol to use when connecting to a broker that has multiple protocols available on a single port, e\&.g\&. MQTT and WebSockets\&.
  358. .RE
  359. .PP
  360. \fB\-\-tls\-engine\fR
  361. .RS 4
  362. A valid openssl engine id\&. These can be listed with openssl engine command\&.
  363. .sp
  364. See also
  365. \fB\-\-keyform\fR\&.
  366. .RE
  367. .PP
  368. \fB\-\-tls\-engine\-kpass\-sha1\fR
  369. .RS 4
  370. 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\&.
  371. .sp
  372. See also
  373. \fB\-\-tls\-engine\fR\&.
  374. .RE
  375. .PP
  376. \fB\-\-tls\-use\-os\-certs\fR
  377. .RS 4
  378. If used, this will load and trust the OS provided CA certificates\&. This can be used in conjunction with
  379. \fB\-\-cafile\fR
  380. and
  381. \fB\-\-capath\fR
  382. and can be used on its own to enable TLS mode\&. This will be set by default if
  383. \fB\-L mqtts://\&.\&.\&.\fR
  384. is used, or if port is 8883 and no other certificate options are used\&.
  385. .RE
  386. .PP
  387. \fB\-\-tls\-version\fR
  388. .RS 4
  389. Choose which TLS protocol version to use when communicating with the broker\&. Valid options are
  390. \fBtlsv1\&.3\fR,
  391. \fBtlsv1\&.2\fR
  392. and
  393. \fBtlsv1\&.1\fR\&. The default value is
  394. \fBtlsv1\&.2\fR\&. Must match the protocol version used by the broker\&.
  395. .RE
  396. .PP
  397. \fB\-u\fR, \fB\-\-username\fR
  398. .RS 4
  399. Provide a username to be used for authenticating with the broker\&. See also the
  400. \fB\-\-pw\fR
  401. argument\&.
  402. .RE
  403. .PP
  404. \fB\-\-unix\fR
  405. .RS 4
  406. Connect to a broker through a local unix domain socket instead of a TCP socket\&. This is a replacement for
  407. \fB\-h\fR
  408. and
  409. \fB\-L\fR\&. For example:
  410. \fBmosquitto_pub \-\-unix /tmp/mosquitto\&.sock \&.\&.\&.\fR
  411. .sp
  412. See the
  413. \fBsocket_domain\fR
  414. option in
  415. \m[blue]\fBmosquitto\&.conf\fR\m[](5)
  416. to configure Mosquitto to listen on a unix socket\&.
  417. .RE
  418. .PP
  419. \fB\-V\fR, \fB\-\-protocol\-version\fR
  420. .RS 4
  421. Specify which version of the MQTT protocol should be used when connecting to the rmeote broker\&. Can be
  422. \fB5\fR,
  423. \fB311\fR,
  424. \fB31\fR, or the more verbose
  425. \fBmqttv5\fR,
  426. \fBmqttv311\fR, or
  427. \fBmqttv31\fR\&. Defaults to
  428. \fB311\fR\&.
  429. .RE
  430. .PP
  431. \fB\-\-will\-payload\fR
  432. .RS 4
  433. 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
  434. \fB\-\-will\-topic\fR\&.
  435. .RE
  436. .PP
  437. \fB\-\-will\-qos\fR
  438. .RS 4
  439. The QoS to use for the Will\&. Defaults to 0\&. This must be used in conjunction with
  440. \fB\-\-will\-topic\fR\&.
  441. .RE
  442. .PP
  443. \fB\-\-will\-retain\fR
  444. .RS 4
  445. 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
  446. \fB\-\-will\-topic\fR\&. Note that zero length payloads are never retained\&. If you send a zero length payload retained message it will clear any retained message on the topic\&.
  447. .RE
  448. .PP
  449. \fB\-\-will\-topic\fR
  450. .RS 4
  451. The topic on which to send a Will, in the event that the client disconnects unexpectedly\&.
  452. .RE
  453. .PP
  454. \fB\-x\fR
  455. .RS 4
  456. 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\&.
  457. .sp
  458. If the session is set to never expire, either with \-x or \-c, then a client id must be provided\&.
  459. .RE
  460. .SH "WILLS"
  461. .PP
  462. mosquitto_sub can register a message with the broker that will be sent out if it disconnects unexpectedly\&. See
  463. \fBmqtt\fR(7)
  464. for more information\&.
  465. .PP
  466. The minimum requirement for this is to use
  467. \fB\-\-will\-topic\fR
  468. to specify which topic the will should be sent out on\&. This will result in a non\-retained, zero length message with QoS 0\&.
  469. .PP
  470. Use the
  471. \fB\-\-will\-retain\fR,
  472. \fB\-\-will\-payload\fR
  473. and
  474. \fB\-\-will\-qos\fR
  475. arguments to modify the other will parameters\&.
  476. .SH "PROPERTIES"
  477. .PP
  478. The
  479. \fB\-D\fR
  480. /
  481. \fB\-\-property\fR
  482. option allows adding properties to different stages of the mosquitto_pub run\&. The properties supported for each command are as follows:
  483. .SS "Connect"
  484. .sp
  485. .RS 4
  486. .ie n \{\
  487. \h'-04'\(bu\h'+03'\c
  488. .\}
  489. .el \{\
  490. .sp -1
  491. .IP \(bu 2.3
  492. .\}
  493. \fBauthentication\-data\fR
  494. (binary data \- note treated as a string in mosquitto_pub)
  495. .RE
  496. .sp
  497. .RS 4
  498. .ie n \{\
  499. \h'-04'\(bu\h'+03'\c
  500. .\}
  501. .el \{\
  502. .sp -1
  503. .IP \(bu 2.3
  504. .\}
  505. \fBauthentication\-method\fR
  506. (UTF\-8 string pair)
  507. .RE
  508. .sp
  509. .RS 4
  510. .ie n \{\
  511. \h'-04'\(bu\h'+03'\c
  512. .\}
  513. .el \{\
  514. .sp -1
  515. .IP \(bu 2.3
  516. .\}
  517. \fBmaximum\-packet\-size\fR
  518. (32\-bit unsigned integer)
  519. .RE
  520. .sp
  521. .RS 4
  522. .ie n \{\
  523. \h'-04'\(bu\h'+03'\c
  524. .\}
  525. .el \{\
  526. .sp -1
  527. .IP \(bu 2.3
  528. .\}
  529. \fBreceive\-maximum\fR
  530. (16\-bit unsigned integer)
  531. .RE
  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. \fBrequest\-problem\-information\fR
  542. (8\-bit unsigned integer)
  543. .RE
  544. .sp
  545. .RS 4
  546. .ie n \{\
  547. \h'-04'\(bu\h'+03'\c
  548. .\}
  549. .el \{\
  550. .sp -1
  551. .IP \(bu 2.3
  552. .\}
  553. \fBrequest\-response\-information\fR
  554. (8\-bit unsigned integer)
  555. .RE
  556. .sp
  557. .RS 4
  558. .ie n \{\
  559. \h'-04'\(bu\h'+03'\c
  560. .\}
  561. .el \{\
  562. .sp -1
  563. .IP \(bu 2.3
  564. .\}
  565. \fBsession\-expiry\-interval\fR
  566. (32\-bit unsigned integer, note use
  567. \fB\-x\fR
  568. instead)
  569. .RE
  570. .sp
  571. .RS 4
  572. .ie n \{\
  573. \h'-04'\(bu\h'+03'\c
  574. .\}
  575. .el \{\
  576. .sp -1
  577. .IP \(bu 2.3
  578. .\}
  579. \fBtopic\-alias\-maximum\fR
  580. (16\-bit unsigned integer)
  581. .RE
  582. .sp
  583. .RS 4
  584. .ie n \{\
  585. \h'-04'\(bu\h'+03'\c
  586. .\}
  587. .el \{\
  588. .sp -1
  589. .IP \(bu 2.3
  590. .\}
  591. \fBuser\-property\fR
  592. (UTF\-8 string pair)
  593. .RE
  594. .SS "Publish"
  595. .sp
  596. .RS 4
  597. .ie n \{\
  598. \h'-04'\(bu\h'+03'\c
  599. .\}
  600. .el \{\
  601. .sp -1
  602. .IP \(bu 2.3
  603. .\}
  604. \fBcontent\-type\fR
  605. (UTF\-8 string)
  606. .RE
  607. .sp
  608. .RS 4
  609. .ie n \{\
  610. \h'-04'\(bu\h'+03'\c
  611. .\}
  612. .el \{\
  613. .sp -1
  614. .IP \(bu 2.3
  615. .\}
  616. \fBcorrelation\-data\fR
  617. (binary data \- note treated as a string in mosquitto_pub)
  618. .RE
  619. .sp
  620. .RS 4
  621. .ie n \{\
  622. \h'-04'\(bu\h'+03'\c
  623. .\}
  624. .el \{\
  625. .sp -1
  626. .IP \(bu 2.3
  627. .\}
  628. \fBmessage\-expiry\-interval\fR
  629. (32\-bit unsigned integer)
  630. .RE
  631. .sp
  632. .RS 4
  633. .ie n \{\
  634. \h'-04'\(bu\h'+03'\c
  635. .\}
  636. .el \{\
  637. .sp -1
  638. .IP \(bu 2.3
  639. .\}
  640. \fBpayload\-format\-indicator\fR
  641. (8\-bit unsigned integer)
  642. .RE
  643. .sp
  644. .RS 4
  645. .ie n \{\
  646. \h'-04'\(bu\h'+03'\c
  647. .\}
  648. .el \{\
  649. .sp -1
  650. .IP \(bu 2.3
  651. .\}
  652. \fBresponse\-topic\fR
  653. (UTF\-8 string)
  654. .RE
  655. .sp
  656. .RS 4
  657. .ie n \{\
  658. \h'-04'\(bu\h'+03'\c
  659. .\}
  660. .el \{\
  661. .sp -1
  662. .IP \(bu 2.3
  663. .\}
  664. \fBtopic\-alias\fR
  665. (16\-bit unsigned integer)
  666. .RE
  667. .sp
  668. .RS 4
  669. .ie n \{\
  670. \h'-04'\(bu\h'+03'\c
  671. .\}
  672. .el \{\
  673. .sp -1
  674. .IP \(bu 2.3
  675. .\}
  676. \fBuser\-property\fR
  677. (UTF\-8 string pair)
  678. .RE
  679. .SS "Disconnect"
  680. .sp
  681. .RS 4
  682. .ie n \{\
  683. \h'-04'\(bu\h'+03'\c
  684. .\}
  685. .el \{\
  686. .sp -1
  687. .IP \(bu 2.3
  688. .\}
  689. \fBsession\-expiry\-interval\fR
  690. (32\-bit unsigned integer)
  691. .RE
  692. .sp
  693. .RS 4
  694. .ie n \{\
  695. \h'-04'\(bu\h'+03'\c
  696. .\}
  697. .el \{\
  698. .sp -1
  699. .IP \(bu 2.3
  700. .\}
  701. \fBuser\-property\fR
  702. (UTF\-8 string pair)
  703. .RE
  704. .SS "Will properties"
  705. .sp
  706. .RS 4
  707. .ie n \{\
  708. \h'-04'\(bu\h'+03'\c
  709. .\}
  710. .el \{\
  711. .sp -1
  712. .IP \(bu 2.3
  713. .\}
  714. \fBcontent\-type\fR
  715. (UTF\-8 string)
  716. .RE
  717. .sp
  718. .RS 4
  719. .ie n \{\
  720. \h'-04'\(bu\h'+03'\c
  721. .\}
  722. .el \{\
  723. .sp -1
  724. .IP \(bu 2.3
  725. .\}
  726. \fBcorrelation\-data\fR
  727. (binary data \- note treated as a string in mosquitto_pub)
  728. .RE
  729. .sp
  730. .RS 4
  731. .ie n \{\
  732. \h'-04'\(bu\h'+03'\c
  733. .\}
  734. .el \{\
  735. .sp -1
  736. .IP \(bu 2.3
  737. .\}
  738. \fBmessage\-expiry\-interval\fR
  739. (32\-bit unsigned integer)
  740. .RE
  741. .sp
  742. .RS 4
  743. .ie n \{\
  744. \h'-04'\(bu\h'+03'\c
  745. .\}
  746. .el \{\
  747. .sp -1
  748. .IP \(bu 2.3
  749. .\}
  750. \fBpayload\-format\-indicator\fR
  751. (8\-bit unsigned integer)
  752. .RE
  753. .sp
  754. .RS 4
  755. .ie n \{\
  756. \h'-04'\(bu\h'+03'\c
  757. .\}
  758. .el \{\
  759. .sp -1
  760. .IP \(bu 2.3
  761. .\}
  762. \fBresponse\-topic\fR
  763. (UTF\-8 string)
  764. .RE
  765. .sp
  766. .RS 4
  767. .ie n \{\
  768. \h'-04'\(bu\h'+03'\c
  769. .\}
  770. .el \{\
  771. .sp -1
  772. .IP \(bu 2.3
  773. .\}
  774. \fBuser\-property\fR
  775. (UTF\-8 string pair)
  776. .RE
  777. .sp
  778. .RS 4
  779. .ie n \{\
  780. \h'-04'\(bu\h'+03'\c
  781. .\}
  782. .el \{\
  783. .sp -1
  784. .IP \(bu 2.3
  785. .\}
  786. \fBwill\-delay\-interval\fR
  787. (32\-bit unsigned integer)
  788. .RE
  789. .SH "EXIT STATUS"
  790. .PP
  791. 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\&.
  792. .PP
  793. MQTT v3\&.1\&.1 CONNACK codes:
  794. .sp
  795. .RS 4
  796. .ie n \{\
  797. \h'-04'\(bu\h'+03'\c
  798. .\}
  799. .el \{\
  800. .sp -1
  801. .IP \(bu 2.3
  802. .\}
  803. \fB0\fR
  804. Success
  805. .RE
  806. .sp
  807. .RS 4
  808. .ie n \{\
  809. \h'-04'\(bu\h'+03'\c
  810. .\}
  811. .el \{\
  812. .sp -1
  813. .IP \(bu 2.3
  814. .\}
  815. \fB1\fR
  816. Connection refused: Bad protocol version
  817. .RE
  818. .sp
  819. .RS 4
  820. .ie n \{\
  821. \h'-04'\(bu\h'+03'\c
  822. .\}
  823. .el \{\
  824. .sp -1
  825. .IP \(bu 2.3
  826. .\}
  827. \fB2\fR
  828. Connection refused: Identifier rejected
  829. .RE
  830. .sp
  831. .RS 4
  832. .ie n \{\
  833. \h'-04'\(bu\h'+03'\c
  834. .\}
  835. .el \{\
  836. .sp -1
  837. .IP \(bu 2.3
  838. .\}
  839. \fB3\fR
  840. Connection refused: Server unavailable
  841. .RE
  842. .sp
  843. .RS 4
  844. .ie n \{\
  845. \h'-04'\(bu\h'+03'\c
  846. .\}
  847. .el \{\
  848. .sp -1
  849. .IP \(bu 2.3
  850. .\}
  851. \fB4\fR
  852. Connection refused: Bad username/password
  853. .RE
  854. .sp
  855. .RS 4
  856. .ie n \{\
  857. \h'-04'\(bu\h'+03'\c
  858. .\}
  859. .el \{\
  860. .sp -1
  861. .IP \(bu 2.3
  862. .\}
  863. \fB5\fR
  864. Connection refused: Not authorized
  865. .RE
  866. .PP
  867. MQTT v5 CONNACK codes:
  868. .sp
  869. .RS 4
  870. .ie n \{\
  871. \h'-04'\(bu\h'+03'\c
  872. .\}
  873. .el \{\
  874. .sp -1
  875. .IP \(bu 2.3
  876. .\}
  877. \fB0\fR
  878. Success
  879. .RE
  880. .sp
  881. .RS 4
  882. .ie n \{\
  883. \h'-04'\(bu\h'+03'\c
  884. .\}
  885. .el \{\
  886. .sp -1
  887. .IP \(bu 2.3
  888. .\}
  889. \fB128\fR
  890. Unspecified error
  891. .RE
  892. .sp
  893. .RS 4
  894. .ie n \{\
  895. \h'-04'\(bu\h'+03'\c
  896. .\}
  897. .el \{\
  898. .sp -1
  899. .IP \(bu 2.3
  900. .\}
  901. \fB129\fR
  902. Malformed packet
  903. .RE
  904. .sp
  905. .RS 4
  906. .ie n \{\
  907. \h'-04'\(bu\h'+03'\c
  908. .\}
  909. .el \{\
  910. .sp -1
  911. .IP \(bu 2.3
  912. .\}
  913. \fB130\fR
  914. Protocol error
  915. .RE
  916. .sp
  917. .RS 4
  918. .ie n \{\
  919. \h'-04'\(bu\h'+03'\c
  920. .\}
  921. .el \{\
  922. .sp -1
  923. .IP \(bu 2.3
  924. .\}
  925. \fB131\fR
  926. Implementation specific error
  927. .RE
  928. .sp
  929. .RS 4
  930. .ie n \{\
  931. \h'-04'\(bu\h'+03'\c
  932. .\}
  933. .el \{\
  934. .sp -1
  935. .IP \(bu 2.3
  936. .\}
  937. \fB132\fR
  938. Unsupported protocol version
  939. .RE
  940. .sp
  941. .RS 4
  942. .ie n \{\
  943. \h'-04'\(bu\h'+03'\c
  944. .\}
  945. .el \{\
  946. .sp -1
  947. .IP \(bu 2.3
  948. .\}
  949. \fB133\fR
  950. Client ID not valid
  951. .RE
  952. .sp
  953. .RS 4
  954. .ie n \{\
  955. \h'-04'\(bu\h'+03'\c
  956. .\}
  957. .el \{\
  958. .sp -1
  959. .IP \(bu 2.3
  960. .\}
  961. \fB134\fR
  962. Bad username or password
  963. .RE
  964. .sp
  965. .RS 4
  966. .ie n \{\
  967. \h'-04'\(bu\h'+03'\c
  968. .\}
  969. .el \{\
  970. .sp -1
  971. .IP \(bu 2.3
  972. .\}
  973. \fB135\fR
  974. Not authorized
  975. .RE
  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. \fB136\fR
  986. Server unavailable
  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. \fB137\fR
  998. Server busy
  999. .RE
  1000. .sp
  1001. .RS 4
  1002. .ie n \{\
  1003. \h'-04'\(bu\h'+03'\c
  1004. .\}
  1005. .el \{\
  1006. .sp -1
  1007. .IP \(bu 2.3
  1008. .\}
  1009. \fB138\fR
  1010. Banned
  1011. .RE
  1012. .sp
  1013. .RS 4
  1014. .ie n \{\
  1015. \h'-04'\(bu\h'+03'\c
  1016. .\}
  1017. .el \{\
  1018. .sp -1
  1019. .IP \(bu 2.3
  1020. .\}
  1021. \fB139\fR
  1022. Server shutting down
  1023. .RE
  1024. .sp
  1025. .RS 4
  1026. .ie n \{\
  1027. \h'-04'\(bu\h'+03'\c
  1028. .\}
  1029. .el \{\
  1030. .sp -1
  1031. .IP \(bu 2.3
  1032. .\}
  1033. \fB140\fR
  1034. Bad authentication method
  1035. .RE
  1036. .sp
  1037. .RS 4
  1038. .ie n \{\
  1039. \h'-04'\(bu\h'+03'\c
  1040. .\}
  1041. .el \{\
  1042. .sp -1
  1043. .IP \(bu 2.3
  1044. .\}
  1045. \fB141\fR
  1046. Keep alive timeout
  1047. .RE
  1048. .sp
  1049. .RS 4
  1050. .ie n \{\
  1051. \h'-04'\(bu\h'+03'\c
  1052. .\}
  1053. .el \{\
  1054. .sp -1
  1055. .IP \(bu 2.3
  1056. .\}
  1057. \fB142\fR
  1058. Session taken over
  1059. .RE
  1060. .sp
  1061. .RS 4
  1062. .ie n \{\
  1063. \h'-04'\(bu\h'+03'\c
  1064. .\}
  1065. .el \{\
  1066. .sp -1
  1067. .IP \(bu 2.3
  1068. .\}
  1069. \fB143\fR
  1070. Topic filter invalid
  1071. .RE
  1072. .sp
  1073. .RS 4
  1074. .ie n \{\
  1075. \h'-04'\(bu\h'+03'\c
  1076. .\}
  1077. .el \{\
  1078. .sp -1
  1079. .IP \(bu 2.3
  1080. .\}
  1081. \fB144\fR
  1082. Topic name invalid
  1083. .RE
  1084. .sp
  1085. .RS 4
  1086. .ie n \{\
  1087. \h'-04'\(bu\h'+03'\c
  1088. .\}
  1089. .el \{\
  1090. .sp -1
  1091. .IP \(bu 2.3
  1092. .\}
  1093. \fB147\fR
  1094. Receive maximum exceeded
  1095. .RE
  1096. .sp
  1097. .RS 4
  1098. .ie n \{\
  1099. \h'-04'\(bu\h'+03'\c
  1100. .\}
  1101. .el \{\
  1102. .sp -1
  1103. .IP \(bu 2.3
  1104. .\}
  1105. \fB148\fR
  1106. Topic alias invalid
  1107. .RE
  1108. .sp
  1109. .RS 4
  1110. .ie n \{\
  1111. \h'-04'\(bu\h'+03'\c
  1112. .\}
  1113. .el \{\
  1114. .sp -1
  1115. .IP \(bu 2.3
  1116. .\}
  1117. \fB149\fR
  1118. Packet too large
  1119. .RE
  1120. .sp
  1121. .RS 4
  1122. .ie n \{\
  1123. \h'-04'\(bu\h'+03'\c
  1124. .\}
  1125. .el \{\
  1126. .sp -1
  1127. .IP \(bu 2.3
  1128. .\}
  1129. \fB148\fR
  1130. Message rate too high
  1131. .RE
  1132. .sp
  1133. .RS 4
  1134. .ie n \{\
  1135. \h'-04'\(bu\h'+03'\c
  1136. .\}
  1137. .el \{\
  1138. .sp -1
  1139. .IP \(bu 2.3
  1140. .\}
  1141. \fB151\fR
  1142. Quota exceeded
  1143. .RE
  1144. .sp
  1145. .RS 4
  1146. .ie n \{\
  1147. \h'-04'\(bu\h'+03'\c
  1148. .\}
  1149. .el \{\
  1150. .sp -1
  1151. .IP \(bu 2.3
  1152. .\}
  1153. \fB152\fR
  1154. Administrative action
  1155. .RE
  1156. .sp
  1157. .RS 4
  1158. .ie n \{\
  1159. \h'-04'\(bu\h'+03'\c
  1160. .\}
  1161. .el \{\
  1162. .sp -1
  1163. .IP \(bu 2.3
  1164. .\}
  1165. \fB153\fR
  1166. Payload format invalid
  1167. .RE
  1168. .sp
  1169. .RS 4
  1170. .ie n \{\
  1171. \h'-04'\(bu\h'+03'\c
  1172. .\}
  1173. .el \{\
  1174. .sp -1
  1175. .IP \(bu 2.3
  1176. .\}
  1177. \fB154\fR
  1178. Retain not supported
  1179. .RE
  1180. .sp
  1181. .RS 4
  1182. .ie n \{\
  1183. \h'-04'\(bu\h'+03'\c
  1184. .\}
  1185. .el \{\
  1186. .sp -1
  1187. .IP \(bu 2.3
  1188. .\}
  1189. \fB155\fR
  1190. QoS not supported
  1191. .RE
  1192. .sp
  1193. .RS 4
  1194. .ie n \{\
  1195. \h'-04'\(bu\h'+03'\c
  1196. .\}
  1197. .el \{\
  1198. .sp -1
  1199. .IP \(bu 2.3
  1200. .\}
  1201. \fB156\fR
  1202. Use another server
  1203. .RE
  1204. .sp
  1205. .RS 4
  1206. .ie n \{\
  1207. \h'-04'\(bu\h'+03'\c
  1208. .\}
  1209. .el \{\
  1210. .sp -1
  1211. .IP \(bu 2.3
  1212. .\}
  1213. \fB157\fR
  1214. Server moved
  1215. .RE
  1216. .sp
  1217. .RS 4
  1218. .ie n \{\
  1219. \h'-04'\(bu\h'+03'\c
  1220. .\}
  1221. .el \{\
  1222. .sp -1
  1223. .IP \(bu 2.3
  1224. .\}
  1225. \fB158\fR
  1226. Shared subscriptions not supported
  1227. .RE
  1228. .sp
  1229. .RS 4
  1230. .ie n \{\
  1231. \h'-04'\(bu\h'+03'\c
  1232. .\}
  1233. .el \{\
  1234. .sp -1
  1235. .IP \(bu 2.3
  1236. .\}
  1237. \fB159\fR
  1238. Connection rate exceeded
  1239. .RE
  1240. .sp
  1241. .RS 4
  1242. .ie n \{\
  1243. \h'-04'\(bu\h'+03'\c
  1244. .\}
  1245. .el \{\
  1246. .sp -1
  1247. .IP \(bu 2.3
  1248. .\}
  1249. \fB160\fR
  1250. Maximum connect time
  1251. .RE
  1252. .sp
  1253. .RS 4
  1254. .ie n \{\
  1255. \h'-04'\(bu\h'+03'\c
  1256. .\}
  1257. .el \{\
  1258. .sp -1
  1259. .IP \(bu 2.3
  1260. .\}
  1261. \fB161\fR
  1262. Subscription IDs not supported
  1263. .RE
  1264. .sp
  1265. .RS 4
  1266. .ie n \{\
  1267. \h'-04'\(bu\h'+03'\c
  1268. .\}
  1269. .el \{\
  1270. .sp -1
  1271. .IP \(bu 2.3
  1272. .\}
  1273. \fB162\fR
  1274. Wildcard subscriptions not supported
  1275. .RE
  1276. .SH "EXAMPLES"
  1277. .PP
  1278. Publish temperature information to localhost with QoS 1:
  1279. .sp
  1280. .RS 4
  1281. .ie n \{\
  1282. \h'-04'\(bu\h'+03'\c
  1283. .\}
  1284. .el \{\
  1285. .sp -1
  1286. .IP \(bu 2.3
  1287. .\}
  1288. mosquitto_pub
  1289. \-t
  1290. sensors/temperature
  1291. \-m
  1292. 32
  1293. \-q
  1294. 1
  1295. .RE
  1296. .PP
  1297. Publish timestamp and temperature information to a remote host on a non\-standard port and QoS 0:
  1298. .sp
  1299. .RS 4
  1300. .ie n \{\
  1301. \h'-04'\(bu\h'+03'\c
  1302. .\}
  1303. .el \{\
  1304. .sp -1
  1305. .IP \(bu 2.3
  1306. .\}
  1307. mosquitto_pub
  1308. \-h
  1309. 192\&.168\&.1\&.1
  1310. \-p
  1311. 1885
  1312. \-t
  1313. sensors/temperature
  1314. \-m
  1315. "1266193804 32"
  1316. .RE
  1317. .PP
  1318. Publish light switch status\&. Message is set to retained because there may be a long period of time between light switch events:
  1319. .sp
  1320. .RS 4
  1321. .ie n \{\
  1322. \h'-04'\(bu\h'+03'\c
  1323. .\}
  1324. .el \{\
  1325. .sp -1
  1326. .IP \(bu 2.3
  1327. .\}
  1328. mosquitto_pub
  1329. \-r
  1330. \-t
  1331. switches/kitchen_lights/status
  1332. \-m
  1333. "on"
  1334. .RE
  1335. .PP
  1336. Send the contents of a file in two ways:
  1337. .sp
  1338. .RS 4
  1339. .ie n \{\
  1340. \h'-04'\(bu\h'+03'\c
  1341. .\}
  1342. .el \{\
  1343. .sp -1
  1344. .IP \(bu 2.3
  1345. .\}
  1346. mosquitto_pub
  1347. \-t
  1348. my/topic
  1349. \-f
  1350. \&./data
  1351. .RE
  1352. .sp
  1353. .RS 4
  1354. .ie n \{\
  1355. \h'-04'\(bu\h'+03'\c
  1356. .\}
  1357. .el \{\
  1358. .sp -1
  1359. .IP \(bu 2.3
  1360. .\}
  1361. mosquitto_pub
  1362. \-t
  1363. my/topic
  1364. \-s
  1365. < \&./data
  1366. .RE
  1367. .PP
  1368. Send parsed electricity usage data from a Current Cost meter, reading from stdin with one line/reading as one message:
  1369. .sp
  1370. .RS 4
  1371. .ie n \{\
  1372. \h'-04'\(bu\h'+03'\c
  1373. .\}
  1374. .el \{\
  1375. .sp -1
  1376. .IP \(bu 2.3
  1377. .\}
  1378. read_cc128\&.pl | mosquitto_pub
  1379. \-t
  1380. sensors/cc128
  1381. \-l
  1382. .RE
  1383. .SH "FILES"
  1384. .PP
  1385. $XDG_CONFIG_HOME/mosquitto_pub, $HOME/\&.config/mosquitto_pub
  1386. .RS 4
  1387. Configuration file for default options\&.
  1388. .RE
  1389. .SH "BUGS"
  1390. .PP
  1391. \fBmosquitto\fR
  1392. bug information can be found at
  1393. \m[blue]\fB\%https://github.com/eclipse/mosquitto/issues\fR\m[]
  1394. .SH "SEE ALSO"
  1395. \fBmqtt\fR(7), \fBmosquitto_rr\fR(1), \fBmosquitto_sub\fR(1), \fBmosquitto\fR(8), \fBlibmosquitto\fR(3), \fBmosquitto-tls\fR(7)
  1396. .SH "AUTHOR"
  1397. .PP
  1398. Roger Light
  1399. <roger@atchoo\&.org>