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

Is it possible to get deviceid from publisher and use this as a variable in a topic in a bridge configuration? #104

Open
frodecat opened this issue Aug 26, 2020 · 2 comments

Comments

@frodecat
Copy link

Hi,

If you want to forward an incoming message to another broker when using bridge configuration, there is a variable called "node" which you can use in the forwarding path. The "node" will give the name of the current Emqx broker.

But is it possible to get the actual deviceid(name) of the IoT device who published a message to the broker and use this variable in the forwarding topic path?

The Azure IoT Hub has this mandatory path for incoming mqtt messages: "devices/deviceid/messages/events". If the IoT devicename was "myIoTdevice" then it would be "devices/myIoTdevice/messages/events".

It would be incredibly helpful if it was possible to read the incoming deviceid and put that in this forwarding path. In example: "/devices/${deviceid}/messages/events". Then we could forward to the correct device in the Azure IoT bridge.

Instead now we have to use only one specific device and let all devices messages going to the Emqx mqtt broker bridge be truncated to this single iot-device name at the Azure IoT Hub and then have to sort out the correct device from the message in some backend afterwards.

Thanks,
Frode

@endianjoakim
Copy link

You can probably use the wildcard. Either "/devices/+/messages/events" or "/devices/#".

@frodecat
Copy link
Author

You can probably use the wildcard. Either "/devices/+/messages/events" or "/devices/#".

Thank you for replying! Yes, that should theoretically solve my initial question.

However I forgot about the Azure authentication part. Now I use a single device in Azure IoT Hub and bridge towards that using clientid, username and certificate (could probably go with password instead of client certificate). But this authentication is only for this single device. So I can only truncate all messages through this 1 device and I can only listen for messages from this single device due to not having permission for the other devices.

So the big question is how Emqx can bridge to Azure IoT in such a way that it can forward messages to the many individual IoT Hub devices and not just to 1 device.

Maybe the access policy "iothubowner" could be used, but since this is more of a user/password thing and not a physical device, what would I put as "deviceid" ? I have tried several combinations of deviceid, user and password, but have yet to be able to get the bridge to authenticate using iothubowner.

Is there anyone who has managed to configure this? Emqx bridge to Azure IoT Hub and transparently sending messages to the correct devices and not just to 1 device ?

Thanks,
Frode

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