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

MQTT Clients compatibility issue with '.' char and use in Eclipse Tahu MQTT specification #1879

Closed
petedavis opened this issue Feb 3, 2021 · 2 comments

Comments

@petedavis
Copy link

There is an issue using NATS.io as a MQTT broker for with the Eclipse Tahu specification.

Unfortunately the root namespace used for the topic contains a '.' char. (See page 12 of the specification)

Given that the '/' topic delimiter chars are converted to NATS topic alternative, should the NATS topic delimiter chars be converted or escaped for MQTT clients?

Could there be a known substitution used internally, like converting '.' to '_' and NATS clients would need to know about?

So MQTT client publish to spBv1.0/group/message/node and NATS client subscribe to spBv1_0.group.message.node?

@kozlovic
Copy link
Member

kozlovic commented Feb 3, 2021

As you have probably observed, currently NATS would reject an MQTT topic that contains '.' because it is used as token delimiter in NATS.

If we do any conversion, then it would be ok to document so that NATS users that want to exchange between NATS and MQTT would have to alter their NATS subjects, however, the problem is that internally NATS converts incoming MQTT messages to NATS format, and convert back when sending to MQTT subscribers.

That is, a MQTT publisher that sends on foo.bar/baz would be converted on ingest to foo_bar.baz, matched against any subscription and then sent to MQTT subscribers as foo.bar/baz (reverse conversion).

Seem ok, right? The issue is if the MQTT topic contains the converted character. In the example above, suppose that MQTT publishes on foo.bar/baz/bar_bat, then it would be converted to foo_bar.baz.bar_bat but on the way to the MQTT subscribers it would have to be converted and now would be foo.bar/baz/bar.bat which does not match.

@sandrokeil
Copy link

See also #3482

derekcollison added a commit that referenced this issue Jun 14, 2023
The `.` character will be transformed to `//` in NATS subject. For
instance an MQTT message published on `spBv1.0/plant1` would be received
by a NATS subscriber as `spBv1//0.plant1`.

Conversely, a NATS message published on `spBv1//0.plant1` would be
received by an MQTT subscriber as `spBv1.0/plant1`.

Resolves #1879
Resolves #3482

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
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