← Back to team overview

mosquitto-users team mailing list archive

Re: Wild card

 

Hi Stefano,

The behaviour you describe is incorrect. It is better explained using
a longer topic - let's set sensors/temperature sensors/humidity etc.

A subscription to sensors/# would match on sensors/temperature,
sensors/humidity *and* sensors. If we imagine that a subscription to
/# is actually a subscription to ""/# (i.e. an empty topic followed by
/ followed by #) then a subscription to /# should match against "" as
well as anything below it such as /foo/bar (""/foo/bar). A
subscription to # on the other hand will match everything, including
""/foo/bar.

The slightly confounding bit is that topics must be at least one
character long, so it is not possible to publish to "", which would
match against ""/#.

The current mosquitto code (you really should upgrade) works correctly
for subscriptions to # but not for retained messages when subscribing
to /# (it returns messages with topics without a leading slash). I'll
get that fixed.

Cheers,

Roger


On Mon, Jun 3, 2013 at 10:22 AM, Stefano Costa
<stefano.costa@xxxxxxxxxxx> wrote:
> Hello,
> I have a doubt about wildcard usage. I can see something (perhaps) strange
> and before investigating in the wrong direction I want to check if this is
> simply my wrong assumption.
>
> What I can see as an example is:
>
> mosquitto_sub -v -h things.bluewind.it -t "#"
> --> this shows immediately all topics that have been published as
> "retained", both beginning or not with a "/":
> --> BUT then will only show topics being published NOT beginning with a "/".
>
>
> mosquitto_sub -v -h things.bluewind.it -t "/#"
> --> this shows immediately only the two topics that have been published as
> "retained" AND begin with a "/":
> --> and then will only show topics being published beginning with a "/".
>
> Is this correct and/or intended behaviour? It seems to me that the second
> situation is correct, but in the first situation I expect a coherent
> behaviour for retained / current pubs (why not show all topics, also
> beginning with a "/"?).
>
> Thanks!! S
>
> --
>   Stefano Costa, R&D Manager
>   M +39 335 6565749
>   Skype stefanocosta.bluewind
>   Twitter @stefanobluewind
>   http://www.bluewind.it
>
> --
> Mailing list: https://launchpad.net/~mosquitto-users
> Post to     : mosquitto-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~mosquitto-users
> More help   : https://help.launchpad.net/ListHelp


Follow ups

References