Azure / iot-edge-v1

Azure IoT Edge
http://azure.github.io/iot-edge/
Other
525 stars 257 forks source link

Can I check if a module is running #628

Closed SachaLhopital closed 6 years ago

SachaLhopital commented 6 years ago

Hi everyone, I am kinda new to azure iot edge and i have a specific question.

So I was able to create my own device with two modules in it.

My iot edge runtime is set up on a Linux amd64 and both modules containers are also linux amd64. Also both modules code is written in Python. The camera-module is working fine communicating <ith the ML module through this url : http://emotion-module:80/image.

When I run everything (iotedgectl start), the communication between the two modules does not work at first, but It works after a while. I believe this is normal since it take some seconds/minutes to my emotion-module to start. Here are the errors received :

MaxRetryError("HTTPConnectionPool(host='emotion-recognition-module', port=80): Max retries exceeded with url: /image (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f63612d7410>: Failed to establish a new connection: [Errno -2] Name or service not known',))",))

After about 1 second, the error then change from my output :

MaxRetryError("HTTPConnectionPool(host='emotion-recognition-module', port=80): Max retries exceeded with url: /image (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f63612d7450>: Failed to establish a new connection: [Errno 111] Connection refused'

And after about 4 seconds of running, here is another error :

Error: Time:Fri Jun 22 14:26:57 2018 File:/usr/sdk/src/c/c-utility/adapters/socketio_berkeley.c Func:socketio_open Line:701 Failure: connect failure 111. Error: Time:Fri Jun 22 14:26:57 2018 File:/usr/sdk/src/c/c-utility/src/tlsio_openssl.c Func:on_underlying_io_open_complete Line:751 Invalid tlsio_state. Expected state is TLSIO_STATE_OPENING_UNDERLYING_IO. Error: Time:Fri Jun 22 14:26:57 2018 File:/usr/sdk/src/c/c-utility/src/tlsio_openssl.c Func:tlsio_openssl_open Line:1251 Failed opening the underlying I/O. Error: Time:Fri Jun 22 14:26:57 2018 File:/usr/sdk/src/c/umqtt/src/mqtt_client.c Func:mqtt_client_connect Line:980 Error: io_open failed Error: Time:Fri Jun 22 14:26:57 2018 File:/usr/sdk/src/c/iothub_client/src/iothubtransport_mqtt_common.c Func:SendMqttConnectMsg Line:1932 failure connecting to address tomtan.

Finally, after another 2 seconds, my code works fine and my module send correct data to my iot hub.

So here is my question : can I check, in my camera-module code, if the emotion-module is on ? And is there a proper way to manage those kinds of networks errors ? Maybe there is a way for me to set up a specific order when starting my modules ?

Thank you for your help and have a good day all !

varunpuranik commented 6 years ago

Hi SachaLhopital,

Since your modules are communicating directly with each other over Http, the communication between them (and the related errors) will have to be handled by the modules themselves. The only thing the Edge runtime checks (and reports) is whether the modules themselves are running, or have failed. If they have failed, it will restart them, depending on the restart policy. But there is no Edge runtime provided way for a module to check if another module is running.

There is no way to specify the order of starting modules. This is by design. Since the modules can fail and restart at random times, the application code is expected to be tolerant to such events, and have the necessary retry logic.

SachaLhopital commented 6 years ago

Thank you for you answers vanrunpuranik ! I will work on that. Have a nice day !