MQTT.md (1348B)
1 <!-- 2 Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 4 SPDX-License-Identifier: curl 5 --> 6 7 # MQTT in curl 8 9 ## Usage 10 11 A plain "GET" subscribes to the topic and prints all published messages. 12 13 Doing a "POST" publishes the post data to the topic and exits. 14 15 16 ### Subscribing 17 18 Command usage: 19 20 curl mqtt://host/topic 21 22 Example subscribe: 23 24 curl mqtt://host.home/bedroom/temp 25 26 This sends an MQTT SUBSCRIBE packet for the topic `bedroom/temp` and listen in 27 for incoming PUBLISH packets. 28 29 You can set the upkeep interval ms option to make curl send MQTT ping requests to the 30 server at an internal, to prevent the connection to get closed because of idleness. 31 You might then need to use the progress callback to cancel the operation. 32 33 ### Publishing 34 35 Command usage: 36 37 curl -d payload mqtt://host/topic 38 39 Example publish: 40 41 curl -d 75 mqtt://host.home/bedroom/dimmer 42 43 This sends an MQTT PUBLISH packet to the topic `bedroom/dimmer` with the 44 payload `75`. 45 46 ## What does curl deliver as a response to a subscribe 47 48 Whenever a PUBLISH packet is received, curl outputs two bytes topic length (MSB | LSB), the topic followed by the 49 payload. 50 51 ## Caveats 52 53 Remaining limitations: 54 - Only QoS level 0 is implemented for publish 55 - No way to set retain flag for publish 56 - No TLS (mqtts) support 57 - Naive EAGAIN handling does not handle split messages