Forum Discussion
Help understanding IoTHubDeviceClient in distributed modules
Thanks for responding and excuse my late reply. I've actually set up provisioning of my devices and that works fine. I did find a discussion regarding the IoTHubModuleClient not receiving a connection as well as not throwing an error under certain circumstances which I sadly can't remember now but this was my issue as well.
I'm trying to find out just how to use the IoTHubModuleClient to send a message to the Hub right now. Is that where the output comes in (via send_message_to_output) or do I still use the
or should I still use the send_message method?
The modules communication is enabled by the Edge Hub module which is part of the IoT Edge runtime. The idea is that you configure routes between modules and up to the IoT Hub service at the IoT Edge runtime level and then in your module you can send messages to the output of the module defined in the routing configuration. You can learn more about the IoT Edge runtime concepts in this article and more on the routing setup in this one.
If you want to send messages to IoT Hub directly from a module then you need to setup a route that takes all outputs from the module and sends to "upstream".
For sending all messages from a specific module to IoT Hub, you would setup the route like this:
"$edgeHub": {
"properties.desired": {
"routes": {
"route1": "FROM /messages/modules/<moduleId>/* INTO $upstream"
},
}
}