Hi All,
I am running a C based custom module in a linux iot edge device.
1) Is it possible subscribe/publish data from inside iot edge module to an MQTT broker(mosquitto) running outside container as a normal linux process ? (My application logic is running in multiple services (normal linux processes out side containers) in the same machine, Currently I just need to connect to Azure edge with my custom module, I am thinking MQTT can be used for inter process communication)
2) If possible please provide some insights to achieve that.
@Anil-Poolayulla-Chelottillam Yes, you should be able to start an MQTT client inside the IoT edge module. You can then tell the client to publish messages to the MQTT server which would run as a normal Linux process. I've done this using UDP, and the process is the same if you were using two different computers.
@lelopez-io Thanks for your comment, its really valuable at this moment for me.
Can I have one more basic question, What are the module configuration changes required to make that communication possible? I red about port forwarding, but not an expert with iot edge/docker systems.
@Anil-Poolayulla-Chelottillam As long as the host machine has open it's port for MQTT messages (8883) your server should receive messages just fine. If the host machine needs to send MQTT messages back down to the container then you will have to look into opening that same port on the container when it is created. This is done using "createOptions": {} in the Azure portal where you specify which module to deploy on the edge device. I suggest looking at this docker document and searching for PortBindings within the ContainerCreate section to get started with two way MQTT communication. If you bind ports this way it will be as if the client and server are running on the same computer and both can possibly target the loopback IP if you wish to limit this MQTT service to internal processes (just be sure to specify which IP and PORT to bind else it binds the port to 0.0.0.0 by default).
Thank you, @lelopez-io , Let me try this :)
Closing this one since there is no updates for about a month. Please reopen if necessary. Thanks.
@lelopez-io, @Anil-Poolayulla-Chelottillam, @rafilho, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey
Its working now.
I added Mosquitto client library download commands in docker file, then used host as bridge docker network ip while subscribing. then it worked. SUB and PUB are working. Thanks fro the support. Note i did not expose additional port for this.