Introduction to MyQtthub filters
With MyQttHub filters you can easily:
- Control what can be PUBLISHed creating policies for allow-then-deny or deny-something-rest-allowed.
- Use filtering to activate Stashing function to store matched messages into durable MyQttHub storage backend.
We are going to see how filters are configured by example. See next.
Creating an allow-then-deny MQTT filter with MyQtthub
In this case you want:
- To create a filter that allows only certain topics.
- Optionally allow these topics only to certain list of users
- Then deny rest of topics PUBLISHed to all users (or optionall to some users).
Go to filters clicking top menu:
…and then Filters:
Now click to add filter (top right):
Now input a label, select a high priority (higher than deny rule; 1 has higher priority than 100), select rule type (limit PUBLISH), leave rule enabled and configure topic filters that are going to be allowed:
Optionally, if you want to limit this rule to a set of clientId devices, input them by clicking to “ClientIds”:
Once you are done, click “Add filter rule”:
If everything went ok, you should see know your “allow” rule. Now, repeat the process to add a lower priority rule that will deny rest of the traffic. Here is how.
Click to add again, configure another label, set same rule type, lower priority, change “Permission/action” to Reject/deny and then add rule:
Optionally, you configure this deny rule to be only applied to certain users.
After this configuration, PUBLISH messages with allowed/matching topic filter will have “Allow/Ok” action, that is, allow/accept this message right now and stop checking other rules.
Rest of messages not matching with previous rule will match with Deny/Reject rule because we have used “#” in our example. In such case, those messages will be discarded.
Creating a MQTT deny filter, then rest allowed with MyQttHub
By default, MyQttHub filter engine will accept/allow any message not matching any rule. So, to create a deny filter to limit certain topics to certain users, you only have to create a deny filter:
Then, rest of messages (PUBLISH) not matching this filter will be allowed.