Can't add permission to topic starting with $

Hi there,

I noticed that I can’t add default permissions to a topic starting with $ (more precisely, $EDC). No error is raised when adding the permission, but later when a client tries to publish on that topic, it gets disconnected. If I replace the dollar with an underscore, everything works fine. I know the $ has a special meaning, but I can’t find anything in the documentation regarding authentication that may explain this behaviour.

Here a very simplified snippet of my code (in my own implementation of the SimpleAuthenticator interface):

public void onConnect(@NotNull final SimpleAuthInput input, @NotNull final SimpleAuthOutput output) {
    var permissions = output.getDefaultPermissions();
    permissions.add(topicPermission().topicFilter("$EDC/blabla").build());
    output.authenticateSuccessfully();
}

Any help or explanation on this? Thanks a lot in advance.

Hi @bgu,

HiveMQ CE as well as HiveMQ 4 PE and EE prohibit the use of topics starting with ‘$’.
Exception being the shared subscription syntax.

See MQTT specification:

The Server MUST NOT match Topic Filters starting with a wildcard character (# or +) with Topic Names
beginning with a $ character [MQTT-4.7.2-1]. The Server SHOULD prevent Clients from using such Topic Names to exchange messages with other Clients. Server implementations MAY use Topic Names that start with a leading $ character for other purposes.

Kind regards,
Florian from the HiveMQ Team.

The Server SHOULD prevent Clients from using such Topic Names to exchange messages with other Clients

Ahhh ok, I didn’t know that. I guess it’s new in MQTT 5.

Thanks a lot.