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

rumqttd: Existing subscription should be updated on re-subscription #682

Open
swanandx opened this issue Aug 13, 2023 · 0 comments · May be fixed by #701
Open

rumqttd: Existing subscription should be updated on re-subscription #682

swanandx opened this issue Aug 13, 2023 · 0 comments · May be fixed by #701
Labels
broker Related to rumqttd good first issue Good for newcomers

Comments

@swanandx
Copy link
Member

swanandx commented Aug 13, 2023

Current behavior:

If a subscription exists, we don't create/update the DataRequest, so it still uses older values present in it.

Expected behavior:

Resubscribing to same filter should update the DataRequest

as per standards at [MQTT-3.8.4-3] :

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. The Topic Filter in the new Subscription will be identical to that in the previous Subscription, although its maximum QoS value could be different. Any existing retained messages matching the Topic Filter MUST be re-sent, but the flow of publications MUST NOT be interrupted

Example

client
  .subscribe("hello", QoS::AtMostOnce)
  .await
  .unwrap();

client
  .subscribe("hello", QoS::ExactlyOnce)
  .await
  .unwrap();

// after this call, our QoS level for "hello" should be updated to ExactlyOnce
// but it still stays AtMostOnce!

Possible Solution

If a subscription ( DataRequest ) exists already here, we should get that DataRequest and update it. To find it, I can think of something like this:

self.scheduler.trackers[id]
    .data_requests
    .iter_mut()
    .find(|r| r.filter_idx == filter_idx)

This may or may not work depending on where the data request is. for example, the DataRequest can be in waiters as well!

PS: Would love to know if there exists any better way to find & update the DataRequest!

@swanandx swanandx added good first issue Good for newcomers broker Related to rumqttd labels Aug 13, 2023
@swanandx swanandx linked a pull request Aug 30, 2023 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broker Related to rumqttd good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant