IoT Edge - AMQP messages are not received, and error in sending the messages RRS feed

  • Question

  • Hi all,

    I'm trying to send/receive messages to/from another iot edge module.

    Following is the code:

    var amqpSetting = new AmqpTransportSettings(TransportType.Amqp_Tcp_Only);
    ITransportSettings[] settings = { amqpSetting };

    // Open a connection to the Edge runtime
    this.IoTHubModuleClient = await ModuleClient.CreateFromEnvironmentAsync(settings);

    await this.IoTHubModuleClient.OpenAsync();

    For receive:

    await this.IoTHubModuleClient.SetInputMessageHandlerAsync("mainInput", this.ReceiveMessage, this.IoTHubModuleClient);

    For send:

    await moduleClient.SendEventAsync("mainOutput", upstreamMessage);

    ReceiveMessage is not being invoked even though the other module is sending the message, and I get following exception after some time for SendEventAsync

    Microsoft.Azure.Devices.Client.Exceptions.IotHubCommunicationException: The operation did not complete within the allocated time 00:01:00 for object message. ---> Microsoft.Azure.Devices.Client.Exceptions.IotH
    ubCommunicationException: The operation did not complete within the allocated time 00:01:00 for object message. ---> System.TimeoutException: The operation did not complete within the allocate
    d time 00:01:00 for object message.
       at Microsoft.Azure.Amqp.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at Microsoft.Azure.Amqp.SendingAmqpLink.EndSendMessage(IAsyncResult result)
       at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.Azure.Devices.Client.Transport.AmqpIoT.AmqpIoTSendingLink.SendAmqpMessageAsync(AmqpMessage amqpMessage, TimeSpan timeout)
       --- End of inner exception stack trace ---
       --- End of inner exception stack trace ---
       at Microsoft.Azure.Devices.Client.Transport.AmqpIoT.AmqpIoTSendingLink.SendAmqpMessageAsync(AmqpMessage amqpMessage, TimeSpan timeout)
       at Microsoft.Azure.Devices.Client.Transport.AmqpIoT.AmqpIoTSendingLink.SendMessageAsync(Message message, TimeSpan timeout)
       at Microsoft.Azure.Devices.Client.Transport.AmqpIoT.AmqpUnit.SendMessageAsync(Message message, TimeSpan timeout)
       at Microsoft.Azure.Devices.Client.Transport.AmqpIoT.AmqpUnit.SendEventAsync(Message message, TimeSpan timeout)
       at Microsoft.Azure.Devices.Client.Transport.Amqp.AmqpTransportHandler.SendEventAsync(Message message, CancellationToken cancellationToken)
       at Microsoft.Azure.Devices.Client.Transport.ErrorDelegatingHandler.<>c__DisplayClass22_0.<<ExecuteWithErrorHandlingAsync>b__0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.Azure.Devices.Client.Transport.ErrorDelegatingHandler.ExecuteWithErrorHandlingAsync[T](Func`1 asyncOperation)
       at Microsoft.Azure.Devices.Client.Transport.RetryDelegatingHandler.<>c__DisplayClass14_0.<<SendEventAsync>b__0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.Azure.Devices.Client.Transport.RetryDelegatingHandler.SendEventAsync(Message message, CancellationToken cancellationToken)
       at Microsoft.Azure.Devices.Client.InternalClient.SendEventAsync(String outputName, Message message)
       at xxxx`1.SendMessage(String messageContent, String correlationId, String messageType, String messageVersion, Object userContext

    But this message is being received in the other IoT edge module.

    Can someone help me with this?



    • Edited by Keshava GN Friday, December 20, 2019 11:25 AM
    Tuesday, October 15, 2019 2:10 AM


All replies

  • Hi Keshava GN is there a guide or tutorial you are following? Can you please share? 

    The IoT Edge hub manages communication between modules, IoT Hub, and any leaf devices. Therefore, the $edgeHub module twin contains a desired property called routes that declares how messages are passed within a deployment. You can have multiple routes within the same deployment.

    Please see this thread and Answer from Rita Han: I hope it helps

    In Azure IoT Edge, messages passed based on declarative routes. Module can set input and output to receive message from and send message to.

    For example this route:

            "routes": {
              "sensorToFilter": "FROM /messages/modules/tempSensor/outputs/temperatureOutput INTO BrokeredEndpoint(\"/modules/filtermodule/inputs/input1\")",
              "filterToIoTHub": "FROM /messages/modules/filtermodule/outputs/output1 INTO $upstream"

    Here tempSensor module specified the output "tempertureOutput" like this:

    await deviceClient.SendEventAsync("temperatureOutput", message);

    And filtermodule specified the input "input1" and "output1" like this:

    // Register callback to be called when a message is received by the module
    await ioTHubModuleClient.SetInputMessageHandlerAsync("input1", FilterMessages, ioTHubModuleClient);
    await moduleClient.SendEventAsync("output1", filteredMessage);

    And $upstream for sending messages to IoT Hub.


    Create an IoT Edge module project

    Using the IoT Edge hub

    Declare routes

    Best regards,


    Saturday, October 19, 2019 12:33 AM
  • I've added a new thread with the actual question, which is route cause for this behavior. Thanks.
    • Edited by Keshava GN Saturday, October 19, 2019 5:54 AM Link
    • Marked as answer by Keshava GN Saturday, October 19, 2019 6:34 AM
    Saturday, October 19, 2019 5:43 AM