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

Subscribe API makes it impossible to match suback reasons to subscribed topics #123

Closed
ewirch opened this issue Mar 19, 2023 · 1 comment

Comments

@ewirch
Copy link
Contributor

ewirch commented Mar 19, 2023

Version: 0.10.0

Client.Subscribe expects a map containing subscription topics as keys:

Subscriptions map[string]SubscribeOptions

Later, these topics are sent to MQTT broker using a for-range loop:

for t, o := range s.Subscriptions {
	writeString(t, &subs)
	subs.WriteByte(o.Pack())
}

for-range loop over a map is specified to have no consistent order ("The iteration order over maps is not specified and is not guaranteed to be the same from one iteration to the next."). Thus, the order in which topics are sent to broker is unknown. There is no way, one could correlate order of suback reasons to subscribed topics:

Suback struct {
	Properties *SubackProperties
	Reasons    []byte
}
alsm added a commit to alsm/paho.golang that referenced this issue May 24, 2023
Enumerating a map isn't deterministic so we can't guarantee an order to
the subscribe packet sent to the server, as the response only contains
a slice of values we need to know what order the subscriptions were sent
in so that the responses can be correlated, using a slice and putting
the topic as a property of the suboptions allows us to be sure of this.

eclipse-paho#123
@MattBrittan
Copy link
Contributor

Closing this as the underlying issue was corrected some time ago (and included in the last release). Subscribe now contains Subscriptions []SubscribeOptions.

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

2 participants