Skip to main content

mqttclient.unsubscribe(topics, callback)

Stop subscribing to a specific MQTT topic or topics




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




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:

Value Description
0 Successfully unsubscribed
-1 The unsubscription attempt failed

An exception will be thrown if you call unsubscribe() on an mqttclient instance that is currently disconnected.