Skip to main content

Unsubscribe from real-time data

Stops delivering realtime_data messages to this connection. The connection stays open and other commands keep working.

Device data is not lost: other subscribed connections of the application receive it, and if there are none, the server accumulates the data in the application queue until the next subscription (consume_req).

Request and response: unconsume_req → unconsume_resp.
Access: a token of any access level.

Current ONS version

The server accepts the unbind field from the v0.17 description, but in the current version it has no effect. The response contains the operation_id from the request and consumer_count.

Request​

Fields not marked as required may be omitted.

FieldTypeDescription
cmdstringunconsume_req
operation_idstringAny string; the server returns it in the response to match the request and the response
unbindboolHas no effect on the server. Default false
{
"cmd": "unconsume_req",
"operation_id": "unsub1"
}

Response​

FieldTypeDescription
cmdstringunconsume_resp
operation_idstringValue from the request
statusuint81 — the connection is unsubscribed, 2 — error
consumer_countuint16How many connections of the application remain subscribed. Only when status = 1
error_code, error_textuint8, stringOnly on error, see below
{
"cmd": "unconsume_resp",
"operation_id": "unsub1",
"status": 1,
"consumer_count": 0
}

Errors​

error_codeerror_textWhat happened
1Not consuming current APPThe connection is not subscribed to data

Good to know​

  • Downlink statuses keep coming. If the connection subscribed with "downlink_status": true, downlink_status messages still arrive after unsubscribing. The status subscription is not removed when the connection closes either — see the downlink_status message.
  • To enable downlink_status for an already subscribed connection, unsubscribe and subscribe again with "downlink_status": true: the flag is applied only when the subscription is made.
  • No need to unsubscribe before closing the connection: the server removes the subscription itself.

See also​