Clients & Sessions
Clients & Sessions
The complete MQTT platform in one small binary: broker, SQL rules, data connectors and multi-tenancy in a single process.
List live client sessions. Use it to find a connected client. You get session ids and detail rows from the session store.
flowchart LR Op["operator"] -- "GET /api/v1/clients" --> API["management API"] API -- "read" --> S["sessions"]Before you start
- Start the broker from First start.
- Set
INDRA_API_KEYto an operator key. The examples read it.
Note: Calls except
/healthzneed an operator API key. Pass it asAuthorization: Bearer $INDRA_API_KEY.
Connected MQTT 3.1.1 / 5.0 client sessions
GET /api/v1/clients
List active client sessions
Operation id: listClients.
Parameters:
No parameters.
Request body:
No request body.
Responses:
| Status | Description |
|---|---|
| 200 | Array of connected client identifiers |
Response 200 body:
Media type application/json:
{ "type": "array", "items": { "type": "string" }}Notes:
- Related calls sit on the same tag page.
Verified: the example flow below runs this call.
Example:
# Illustrative request. Values come from the schema above.# The example flow below runs verified calls on a live broker.curl -s -X GET 'http://127.0.0.1:18083/api/v1/clients' \ -H "Authorization: Bearer $INDRA_API_KEY"GET /api/v1/clients/{id}
Get detailed client session information
Operation id: getClientDetail.
Parameters:
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id | path | true | string | Client ID |
Request body:
No request body.
Responses:
| Status | Description |
|---|---|
| 200 | Client session details |
| 404 | Client not found |
Response 200 body:
Media type application/json:
{ "type": "object", "properties": { "client_id": { "type": "string" }, "session_id": { "type": "integer" }, "conn_id": { "type": "integer" }, "keepalive_secs": { "type": "integer" }, "clean_start": { "type": "boolean" }, "connected": { "type": "boolean" }, "queued": { "type": "integer" }, "subscriptions": { "type": "array", "items": { "type": "string" } } }}Notes:
-
An unknown id fails with 404.
-
Related calls sit on the same tag page.
Not verified: see ../_verification/failures.md.
Example:
# Illustrative request. Values come from the schema above.# The example flow below runs verified calls on a live broker.curl -s -X GET 'http://127.0.0.1:18083/api/v1/clients/1' \ -H "Authorization: Bearer $INDRA_API_KEY"Example flow
Read real rows through the management API, then read them back. The docs harness runs this flow against a started broker.
python3 - <<'PY'import os, urllib.requestport = os.environ.get("API_PORT", "18083")key = os.environ.get("API_KEY", "")base = f"http://127.0.0.1:{port}"def get(path): req = urllib.request.Request(base + path, method="GET") req.add_header("Authorization", f"Bearer {key}") with urllib.request.urlopen(req, timeout=5) as r: return r.status, r.read().decode()s1, b1 = get("/api/v1/clients")assert s1 == 200, b1assert b1.strip().startswith("["), b1s2, b2 = get("/api/v1/clients")assert s2 == 200, b2assert b1 == b2, "read back the same client list"print("OK")PYOKCheck that it works
Start the broker with this file. The health endpoint returns OK.
[node]id = "doc-ref"
[listeners.tcp]bind = "0.0.0.0:1883"
[listeners.tls]bind = "0.0.0.0:8883"
[listeners.ws]bind = "0.0.0.0:8083"
[listeners.wss]bind = "0.0.0.0:8084"
[listeners.api]bind = "0.0.0.0:18083"
[logging]level = "warn"python3 - <<'PY'import os, socketport = int(os.environ.get("API_PORT", "18083"))sock = socket.create_connection(("127.0.0.1", port), timeout=5)sock.sendall(b"GET /healthz HTTP/1.0\r\nHost: docs\r\n\r\n")print(sock.makefile().read().strip().splitlines()[-1])PYOKCheck one documented call. GET /api/v1/clients answers 200 with its rows. It prints OK.
python3 - <<'PY'import os, urllib.requestport = os.environ.get("API_PORT", "18083")key = os.environ.get("API_KEY", "")base = f"http://127.0.0.1:{port}"req = urllib.request.Request(base + "/api/v1/clients", method="GET")req.add_header("Authorization", f"Bearer {key}")with urllib.request.urlopen(req, timeout=5) as r: body = r.read().decode() assert r.status == 200, bodyassert body.strip().startswith("["), bodyprint("OK")PYOKNext steps
- API reference: the other tags.
- Configuration reference: the settings behind the rows.
- Metrics reference: the counter names.