MQTT client disconnects with incorrect topic subscription

Windows 10 pro
Touchdesigner 2022.33910

If you subscribe to an invalid topic, the MQTT client DAT will disconnect and forget all subscriptions.

Instead, it should throw an error for the incorrect topic and keep the established connection.

try this one

op(“mqttclient1”).subscribe(‘/topic/#/invalid/’)

For MQTT spec, wildcards inside a topic should be ‘+’.

This is definitely a user error, but no errors were thrown on TD and all subscriptions are lost when it disconnects.

What broker are you using? It sounds like it’s the MQTT broker that’s aborting the connection.

We’re not doing any client-side validation of topic names and I don’t think we should be, since it’s impossible for us to know what the broker deems a valid or invalid topic. With certain brokers ‘A#’, or ‘/topic/#/valid/’ may be valid topic names and we wouldn’t want to restrict that, even if it may go against the standard naming convention.

Do any of your onSubscribeFailure, onConnectFailure, or onConnectionLost callbacks get triggered?

Those are good points, testing with Mosquitto but considering others. What MQTT server do you prefer?

It does throw onSubscribeFailure and then onConnectionLost, so I think that solves my issues, thanks

@harveymoon

Try RabbitMQ maybe ?

https://www.rabbitmq.com/mqtt.html

Best,
Michel

EDIT: There is a windows installer, or you can use a prebuilt Docker container as well :slight_smile:

1 Like