1

Update

Updating my question for clarity.

Repo: https://github.com/aaronprince05/IoTEdgeMessaging

I have 2 modules: MessageGeneratorModule, MessageReceiverModule.

MessageGeneratorModule sends:
1000 messages in a batch and then waits 4 minutes
1 message/minute for 2 minutes
Then 1 message/second for 1 minute
Then 20 messages/second for 1 minute

MessageReceiverModule is the standard IoT Edge Module boilerplate code that just receives messages and logs them. I've removed the code that sends the messages upstream.

I have a route configuration in IoT Edge as

{
    "routes": {
        "myRoute": "FROM /messages/modules/messageGenerator/outputs/output INTO BrokeredEndpoint(\"/modules/messageReceiver/inputs/input1\")"
    }
}

I'm experiencing some type of throttling here where the messages don't seem to be delivered to the receiver immediately. Instead, about 10-20 of the total messages are delivered. The next set of 10 messages can be forced by sending another message to trigger the receiver. (Notice the timestamps below)

Added Cert: /mnt/edgemodule/edge-device-ca.cert.pem
Connection String <my connection string>
IoT Hub module client initialized.
[12/19/2017 18:27:08] Received message: 1, Body: [1]
[12/19/2017 18:27:08] Received message: 2, Body: [2]
[12/19/2017 18:27:08] Received message: 3, Body: [3]
[12/19/2017 18:27:08] Received message: 4, Body: [4]
[12/19/2017 18:27:08] Received message: 5, Body: [5]
[12/19/2017 18:27:08] Received message: 6, Body: [6]
[12/19/2017 18:27:08] Received message: 7, Body: [7]
[12/19/2017 18:27:08] Received message: 8, Body: [8]
[12/19/2017 18:27:08] Received message: 9, Body: [9]
[12/19/2017 18:27:08] Received message: 10, Body: [10]
[12/19/2017 18:27:08] Received message: 11, Body: [11]
[12/19/2017 18:27:08] Received message: 12, Body: [12]
[12/19/2017 18:27:08] Received message: 13, Body: [13]
[12/19/2017 18:27:08] Received message: 14, Body: [14]
[12/19/2017 18:27:08] Received message: 15, Body: [15]
[12/19/2017 18:27:08] Received message: 16, Body: [16]
[12/19/2017 18:27:08] Received message: 17, Body: [17]
[12/19/2017 18:27:08] Received message: 18, Body: [18]
[12/19/2017 18:27:08] Received message: 19, Body: [19]
[12/19/2017 18:27:08] Received message: 20, Body: [20]
[12/19/2017 18:27:08] Received message: 21, Body: [21]
[12/19/2017 18:30:59] Received message: 22, Body: [22]
[12/19/2017 18:30:59] Received message: 23, Body: [23]
[12/19/2017 18:30:59] Received message: 24, Body: [24]
[12/19/2017 18:30:59] Received message: 25, Body: [25]
[12/19/2017 18:30:59] Received message: 26, Body: [26]
[12/19/2017 18:30:59] Received message: 27, Body: [27]
[12/19/2017 18:30:59] Received message: 28, Body: [28]
[12/19/2017 18:30:59] Received message: 29, Body: [29]
[12/19/2017 18:30:59] Received message: 30, Body: [30]
[12/19/2017 18:30:59] Received message: 31, Body: [31]
[12/19/2017 18:31:59] Received message: 32, Body: [32]
[12/19/2017 18:31:59] Received message: 33, Body: [33]
[12/19/2017 18:31:59] Received message: 34, Body: [34]

The rest of the logs can be found in the repo. You should be able to pull down the code and run it to see the anomaly.

Aaron Prince
  • 170
  • 7

2 Answers2

2

Thanks a lot for reporting this. The code you posted helped a lot to investigate the issue. And you are right, it's a bug. So, I've open this issue here on GitHub so you know when it's fixed: https://github.com/Azure/iot-edge/issues/455

Basically there is a problem on Edge Hub when it's receiving big batches of messages at one time. So, as a work around, if you want to send 1000 messages, instead of sending in one batch of 1000, send in multiple batches of 10.

This is just temporarily till we fill this issue.

[Update] Item fixed on 1.0.0-preview019 release.

0

I am not sure where is _module coming from? My module - which is derived from the official example, uses the DeviceClient like this - within the MessageHandler method:

DeviceClient deviceClient = (DeviceClient)userContext;
// Build your message
//...
await deviceClient.SendEventAsync("output1", identifiedMessage);

Does this work for you?

silent
  • 14,494
  • 4
  • 46
  • 86
  • `_module` comes from a class i created to abstract away the `DeviceClient` connections. That class has `DeviceClient.CreateFromConnectionString(_connectionString, settings);` In any case, the code never reaches the `await _module.SendMessageAsync(identifiedMessage);` to pass the received message onward. The first thing the handler should do is log "Message!" to the console. – Aaron Prince Dec 18 '17 at 17:29
  • Is your code based on the IoT client SDK? The modules have a bit of a different way of working. Also the code I used from https://learn.microsoft.com/en-us/azure/iot-edge/tutorial-csharp-module, uses SendEventAsync() whereas you use SendMessageAsync() – silent Dec 18 '17 at 18:41
  • Yes, I used the code from the docs as a starting point. The `SendMessageAsync` is my method sitting in a class I created called `IoTEdgeModule` so that I can send strings and the method takes care of turning the string into a `Message` along with some logging to the console whenever a message is sent. I'll eventually have a handful of modules all needing to talk to each other so placing the code for connecting and sending messages into a common library seemed like the right idea. I've updated my post to include the `SendMessageAsync()` method. – Aaron Prince Dec 18 '17 at 19:23
  • ok. So can you test it with getting the DeviceClient from the context instead? Just to see if this might be the issue. – silent Dec 18 '17 at 19:26
  • I'm actually having problems receiving the message on ModuleB, not sending them from ModuleB. The `PipeMessage` method in the original post is the receiver for ModuleB. ModuleA doesn't have a `PipeMessage` of its own because it doesn't take input as messages. ModuleA's sole responsibility is to grab files and send messages. In this scenario, there is no `userContext` for ModuleA because that would be passed from a receiving function (like PipeMessage). Since ModuleA doesn't need to receive messages, it doesn't have a `userContext`. – Aaron Prince Dec 18 '17 at 19:45
  • Also, the first thing the PipeMessage is supposed to do is Console.WriteLine. When ModuleB is acting up and not responding anymore, it never sends that: "Message!" – Aaron Prince Dec 18 '17 at 19:49