MQTT: Wildcard support

arunvtec
Posts: 2
Joined: Tue Nov 19, 2019 10:30 am

MQTT: Wildcard support

Postby arunvtec » Tue Nov 19, 2019 10:40 am

Hello,

Does the ESP-MQTT support wildcard in the MQTT topic? Is there an example on this?

I published the topic -

Code: Select all

/multisensor/device-ID/measurements/temperature/GET
and it works fine.

But with wildcard in the topic

Code: Select all

/multisensor/+/measurements/temperature/GET
, there is no response. 'mqtt_event_handler' is never called.

Thanks,
Arun

ESP-Marius
Posts: 74
Joined: Wed Oct 23, 2019 1:49 am

Re: MQTT: Wildcard support

Postby ESP-Marius » Wed Nov 20, 2019 8:40 am

Which version are you running (IDF and MQTT)?

It worked fine when I tested it right now with the master branch and a local Mosquitto broker.

Subscribing to

Code: Select all

/topic/+/esp32
and then publishing to

Code: Select all

 /topic/qos0/esp32

Code: Select all

 /topic/qos1/esp32

Code: Select all

/topic/qos2/esp32
gives me the expected result. I receive the data from all the published messages.

Could it be that your broker doesn't support wildcards?

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: MQTT: Wildcard support

Postby tommeyers » Wed Nov 20, 2019 4:36 pm

I have a feeling that the OP is publishing a wildcard not subscribing with a wildcard. OP what do you say. Sorry if I am wrong.
IT Professional, Maker
Santiago, Dominican Republic

ESP-Marius
Posts: 74
Joined: Wed Oct 23, 2019 1:49 am

Re: MQTT: Wildcard support

Postby ESP-Marius » Thu Nov 21, 2019 12:50 am

tommeyers wrote:
Wed Nov 20, 2019 4:36 pm
I have a feeling that the OP is publishing a wildcard not subscribing with a wildcard. OP what do you say. Sorry if I am wrong.
Re-reading the question I see that you are probably right.

OP: if you are trying to publish with a wildcard then the answer is that this is not a part of the MQTT spec.

It says that:
The Topic Name in the PUBLISH Packet MUST NOT contain wildcard characters

Although technically there should be nothing in the esp MQTT client preventing you from publishing to an invalid topic, we don't do any checks on the content of the topic, but a well-behaving broker will probably close the connection.

tommeyers
Posts: 184
Joined: Tue Apr 17, 2018 1:51 pm
Location: Santiago, Dominican Republic

Re: MQTT: Wildcard support

Postby tommeyers » Fri Nov 22, 2019 9:21 pm

One other suggestion:

My MQTT broker (mosquitto) gives me some tools for debug and monitor:

I can start the broker with verbose logging and see all kinds of events

There is a generic subscriber

There is a generic publisher.

Good tools for an MQTT developer.

Tom Meyers
IT Professional, Maker
Santiago, Dominican Republic

Who is online

Users browsing this forum: No registered users and 417 guests