Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching topic for subscribe/unsubscribe #260

Closed
juliandroid opened this issue Nov 15, 2018 · 2 comments
Closed

Matching topic for subscribe/unsubscribe #260

juliandroid opened this issue Nov 15, 2018 · 2 comments

Comments

@juliandroid
Copy link

juliandroid commented Nov 15, 2018

I see different behaviour between subscribing in different order:

  1. topic/test/#
  2. topic/test/another

and in reverse:

  1. topic/test/another
  2. topic/test/#

In the first case match(topic) @ router.go:108 returns true when you try to subscribe for topic/test/another, which effectively overwrites the wildcard subscription and leaves only topic/test/another

However in the second case, for the second subscription call to topic/test/# does not match, so effectively you have both subscriptions.

I'm not sure what is correct behaviour, but as far as I understand this:

If a Server receives a SUBSCRIBE Packet containing a Topic Filter that is identical to an existing Subscription’s Topic Filter then it MUST completely replace that existing Subscription with a new Subscription.

As if two topic patterns matches literally, so both topic/test/another and topic/test/# are not identical (second one is more broader).

I.e.:
When Clients make subscriptions with Topic Filters that include wildcards, it is possible for a Client’s subscriptions to overlap so that a published message might match multiple filters. In this case the Server MUST deliver the message to the Client respecting the maximum QoS of all the matching subscriptions

I would expect to have both. From current implementation I see func match(route []string, topic []string) that is called recursively which seems to perform level by level checks instead of simple string match. What is the rational? Maybe I miss key point in the specification that requires that logic?

@alsm
Copy link
Contributor

alsm commented Nov 23, 2018

Interesting, yeah, this has been wrong for a long time. I probably just used the match for comparison as I was thinking about topics and delivery rather than it was a comparison.

@MattBrittan
Copy link
Contributor

I believe that this was addresses in PR #388 so am closing this (age/inactivity). Please feel free to reopen if you believe it has not been addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants