summaryrefslogtreecommitdiff
path: root/docs/internals/MQTT.md
blob: 9b8d0efaae2dde66a64c55e388f09199341084a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!--
Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.

SPDX-License-Identifier: curl
-->

# MQTT in curl

## Usage

A plain "GET" subscribes to the topic and prints all published messages.

Doing a "POST" publishes the post data to the topic and exits.


### Subscribing

Command usage:

    curl mqtt://host/topic

Example subscribe:

    curl mqtt://host.home/bedroom/temp

This sends an MQTT SUBSCRIBE packet for the topic `bedroom/temp` and listen in
for incoming PUBLISH packets.

You can set the upkeep interval ms option to make curl send MQTT ping requests to the
server at an internal, to prevent the connection to get closed because of idleness.
You might then need to use the progress callback to cancel the operation.

### Publishing

Command usage:

    curl -d payload mqtt://host/topic

Example publish:

    curl -d 75 mqtt://host.home/bedroom/dimmer

This sends an MQTT PUBLISH packet to the topic `bedroom/dimmer` with the
payload `75`.

## What does curl deliver as a response to a subscribe

Whenever a PUBLISH packet is received, curl outputs two bytes topic length (MSB | LSB), the topic followed by the
payload.

## Caveats

Remaining limitations:
 - Only QoS level 0 is implemented for publish
 - No way to set retain flag for publish
 - No TLS (mqtts) support
 - Naive EAGAIN handling does not handle split messages