emqx/emqx-bridge-mqtt

Forwarding client data with client info

berayb opened this issue · 3 comments

Currently forwarding all data with the following config:
$share/${group_id}/+

However, this only yields the data itself. Which syntax would also include the client information?

Thanks,

Hi @berayb In the emqx-bridge-mqtt plugin, It doesn't get any information from the sender.

But, in the Rule-Engine, you can get at most the username and clientid of the sender. Here are an example data in the Rule-Engine:

##SQL
SELECT
  *
FROM
  "t/#"

## Results
{
  "username": "u_emqx",
  "topic": "t/a",
  "timestamp": 1604539001555,
  "qos": 1,
  "publish_received_at": 1604539001555,
  "peerhost": "127.0.0.1",
  "payload": "{\"msg\":\"hello\"}",
  "node": "052dd2278bc0@172.17.0.2",
  "metadata": {
    "rule_id": "test_rule5f78c83d"
  },
  "id": "5B351D9374ABC18AC0000077F0000",
  "flags": {
    "sys": true,
    "event": true
  },
  "clientid": "c_emqx"
}

And you can pick up some field of this, then Republish it with Republish Action Handler

Thanks, @HJianBo. Moving to rules for typical data flow is on our roadmap. However, is it possible to add client id into the classic bridge method? This might be a quite helpful feature.

Don't worry, I believe that bridging data to MQTT-Broker in Rule-Engine is also fully supported by your bridging needs!