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 Bridge - Allow prefix/suffix to remap of topics #1746

Open
aitorroca opened this issue Apr 13, 2024 · 2 comments
Open

MQTT Bridge - Allow prefix/suffix to remap of topics #1746

aitorroca opened this issue Apr 13, 2024 · 2 comments
Labels

Comments

@aitorroca
Copy link

Is your feature request related to a problem? Please describe.
Configuring a bridge, if you try to rewrite the topic with a wildcard:

forwards = [
  {
    remote_topic = "device_id/topic1/#"
    local_topic = "topic1/#"
  },
]

It shows:

2024-04-13 16:47:23 [1] ERROR /home/runner/work/nanomq/nanomq/nng/src/supplemental/nanolib/conf_ver2.c:970 conf_bridge_node_parse: No wildcard +/# should be contained in remote topic in forward rules.

Similar issues: #1684, #1463, #1174 (comment)

Describe the solution you'd like
Similar to what eclipse mosquitto allows: "The local-prefix and remote-prefix options allow topics to be remapped when publishing to and receiving from remote brokers. This allows a topic tree from the local broker to be inserted into the topic tree of the remote broker at an appropriate place." (https://mosquitto.org/man/mosquitto-conf-5.html)

As example, in mosquitto, that configuration line allows to remap (adding a prefix in the remote topic) with a wildcard:

topic topic1/# both 0 "" device_id/

Describe alternatives you've considered
Right now, the alternative I've tested is:

{
remote_topic = ""
local_topic = "device_id /topic1/#"
}

That works, but it doesn't allow a topic to be remapped with a wildcard, moving more work to the local configuration part.

@RanMaoyi
Copy link
Contributor

Thank you for taking the time to share your suggestion with us. Your proposed enhancement is indeed interesting and aligns well with our goals for further development. We will carefully consider it as we plan our roadmap for future updates.

@JaylinYu
Copy link
Member

JaylinYu commented May 9, 2024

Nope, MQTT forbidden you to publish msg to wildcard. simply cannot.
What you really are asking for is a prefix/suffix of the remote topic that allows modifying topic tree in the remote broker. the way mosquito implement it make it looks like you are publishing msg to wildcard.

we probably gonna add a new config param in bridging section: prefix and suffix

@JaylinYu JaylinYu changed the title MQTT Bridge - Allow wildcard and remap of topics MQTT Bridge - Allow prefix/suffix to remap of topics May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants