Unsubscribing from topics

Prerequisites
  • You must have a WebSocket secure connection to the switch.

  • The switch must have REST API access enabled. The REST API access mode can be either read-only or read/write.

Procedure
Use the WebSocket secure connection to send an unsubscribe message that specifies the topic or topics from which you no longer want notifications.

Use a comma to separate topics in a list of topics.

You must be connected as the same subscriber that subscribed to the topic. For example, you must be using the same web browser connection or be passing the same session cookie with the request.

For example, to unsubscribe to notifications from the default VRF, send the following message through the WebSocket secure connection:
{
  "type": "unsubscribe",
  "topics": [
    {
      "name": "/rest/v1/system/vrfs/default"
    }
  ]
}

If the subscriber does not have a subscription to that topic, the following message is returned:

{
  "type": "error",
  "message": "No subscription for topic(s) <topic-name>."
}

The error can indicate that you have already unsubscribed, the connection was lost, or you attempted to unsubscribe from a different subscriber.

If the request is successful, the following message is returned:

{
  "type": "success",
  "message": "Successfully unsubscribe."
}