Hello Alex,
Removing all subscriptions using the API
Currently there is no general button to allow easy removal for all subscriptions. However, you can use the API to list your current subscriptions:
Then, for each subscription found, based on some criteria, you can remove then using:
Here is a fully working example that combines these two APIs to list your subscriptions and remove some of them. You can run this in the javascript console after complete login into the MyQttHub panel with an admin user:
myqtt.post ({
url : '/get-domain-subscriptions',
data : {domainName : 'hub-xxxxx'},
success : function (subscriptions) {
for (var index in subscriptions) {
var subscription = subscriptions[index];
if (subscription.topicFilter == "some-topic-filter") {
console.log ("Removing subscription=" + subscription.topicFilter + ", qos=" + subscription.qos + ", clientId=" + subscription.clientId);
myqtt.post ({
url : '/unsubscribe',
data : {domainName : 'hub-xxxx', clientId : subscription.clientId, subscriptions : [subscription.topicFilter]}
});
}
}
}
});
Note myqtt.post javascript API is the built-in function that launches API calls based on the protocol, parameters and urls described in the REST API documentation.
How to avoid having that subscriptions for _virt_ clientIds
There is a bug in the MyQttHub engine, that is already solved, and will be pushed to production soon, that causes subscriptions for devices with skipConnectionReplace enabled, to retain after that device disconnect withtout unsubscribing those topics.
Until fix is pushed to production, make sure your devices configured with skipConnectionReplace to unsubscribe everything before disconnecting.
In the meantime, you can save previous javascript block of code to make fast house keeping for subscriptions that shouldn’t be there.
Best Regards,