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

Incomplete decoding of topic names #30

Closed
dg6nee opened this issue Mar 17, 2022 · 4 comments
Closed

Incomplete decoding of topic names #30

dg6nee opened this issue Mar 17, 2022 · 4 comments

Comments

@dg6nee
Copy link

dg6nee commented Mar 17, 2022

I have a device with a MQTT broker and a local client (just as in the example code). On the device side I publish two topics with similar names, where the name of the second is included in the name of the first, as this:
a) sensor/temperature (a floating point value, encoded as string, e.g. "19.8")
b) sensor/temperature_raw (a raw decimal value, e.g. 19384)

When I query the value of "temperature_raw" from a remote machine (e.g. by using mosquitto_sub) it seems that the broker does not properly evaluate the topic name, as it returns the value of "temperature" instead.

This bug is 100% reproducible and can be easily worked around by renaming the topic, in my case it started to work as expected after I renamed the topic to "sensor/raw_temperature".

However, this may be problematic when using nested topics, for example "/actor/xxx" for a read-only value and "/actor/xxx/set" for writing.

@dg6nee
Copy link
Author

dg6nee commented Aug 4, 2022

update:
reason is the incomplete string compare in StringIndexer::strToIndex.
The code should not only do a strncmp - it must also check the length of the strings to be equal!

Otherwise you will get wrong matches. Just an other example:

/blabla/sensor/window_open
/blabla/sensor/wind

-> guess which one will be found if calling the function with /blabla/sensor/wind !

@dg6nee
Copy link
Author

dg6nee commented Aug 4, 2022

see pull request #36

@hsaturn
Copy link
Owner

hsaturn commented Oct 30, 2022

Fixed with this commit

@hsaturn hsaturn closed this as completed Oct 30, 2022
@hsaturn
Copy link
Owner

hsaturn commented Oct 30, 2022

Released in version 0.9.3

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