emqx / emqx-bridge-mqtt

Bridge of MQTT (deprecated since EMQX v5)
https://www.emqx.com
Apache License 2.0
37 stars 13 forks source link

Forwarding client data with client info #113

Open berayb opened 3 years ago

berayb commented 3 years ago

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,

HJianBo commented 3 years ago

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

berayb commented 3 years ago

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.

HJianBo commented 3 years ago

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