Skip to main content

mqttclient.unsubscribe(topics, callback)

Stop subscribing to a specific MQTT topic or topics

Availability

Agent

Parameters

Name Type Description
topics String, blob or array of strings/blobs Topic(s) to be unsubscribed. Each Must be valid UTF-8
callback Function Called when the broker responds to the unsubscribe request

Returns

Nothing

Description

This method allows you to end a subscription to one or more topics.

The callback function is executed when the agent receives an unsubscribe acknowledgement from the MQTT broker. It has one parameter, resultCode, into which an integer response code will be passed:

Result Code Value Description
SUCCESS 0 OK
FAILURE -1 Socket error
ERROR_DISCONNECTED -3 Disconnected
ERROR_NO_MORE_MSGIDS -10 Exhausted MQTT message IDs, ie. greater than 65535
ERROR_OPERATION_INCOMPLETE -11 Operation incomplete (a partial operation was discarded)