Azure / iotedge

The IoT Edge OSS project
MIT License
1.45k stars 458 forks source link

Apparent Timing Issue #1478

Closed ewertons closed 5 years ago

ewertons commented 5 years ago

Filing on behalf of @sasajl


Description of the issue:

In production, messages are not being received on a defined Module Client output . However, message routing works in the IoT Edge Runtime simulator and also works in production if debug level logging is enabled on the IoT Edge runtime. IoT Edge engineering team has been engaged and did not see any issues. Adding a delay to the container entry script works around the issue.

  1. Used the Simulated Temperature App to generate data
  2. Used a second container with routes connecting I/O between the 2 containers
  3. When the containers start, the data should flow from the Temp thru the Edge Runtime to our container. This only works when the start of our consuming container has a delay added (10 seconds, maybe less would work).

Code sample exhibiting the issue:

From the sample program, maybe it has to do with the srand() call? Just guessing here. void sampleConnector::iothub_module() { srand((unsigned int)time(NULL));

if (iotHubModuleClientHandle == NULL)
{
    iotHubModuleClientHandle = InitializeConnection();
}
if (iotHubModuleClientHandle != NULL)
{
    if (SetupCallbacksForModule(iotHubModuleClientHandle) == 0)
    {
        // The receiver just loops constantly waiting for messages.
        printf("Waiting for incoming messages.\r\n");
        while (0 == _pubThreadStop.get()) {
            IoTHubModuleClient_LL_DoWork(iotHubModuleClientHandle);
            ThreadAPI_Sleep(100);
        }
    }
}

DeInitializeConnection(iotHubModuleClientHandle);

}

Console log of the issue:

varunpuranik commented 5 years ago

@sasajl / @ewertons, Is the issue that the receiver module sometimes does not receive messages being sent by EdgeHub? From the information provided, this does seem like a timing related issue, but I am not sure if it is on the EdgeHub side. It is not clear whether the client is able to successfully connect to EdgeHub in the first place. Can you provide EdgeHub debug logs for the repro scenario? If you are unable to repro it with debug logs on, the info logs should also give us some insights into what is going on.

sasajl commented 5 years ago

It may be some time to recreate the problem and collect the log. I'm also on vacation shortly. Please check back in a few weeks. thanks.

arsing commented 5 years ago

Please open a new issue with the logs (and the rest of our issue template) when you get back.