Как сделать так, чтобы маршрутизация сообщений Iot Edge между модулями работала на arm32 (Raspberry Pi) - PullRequest
0 голосов
/ 20 декабря 2018

Я создал решение Iot Edge, используя код Visual Studio через Вид -> Палитра команд ... -> AzureIotEdge: NewIoTEdgeSolution , используя Модуль C # Шаблон модуля.Это создает решение Iot Edge с двумя модулями: tempSensor создает сообщения с фиктивными данными телеметрии, а SampleModule должен получать эти сообщения, распечатывать их и затем передавать их в IotHub.

Я создаю решение для arm32 и развернул его на Rasperry Pi (работает последняя версия Raspbian).Затем модули отображаются как работающие на устройстве, но если я наблюдаю за d2c-сообщениями, они не поступают в IoT Hub.

Если я запускаю sudo iotedge logs tempSensor -f на устройстве,Я вижу, что сообщения генерируются.

Если я запускаю sudo iotedge logs SampleModule -f Я вижу только Инициализированный клиент модуля IoT Hub. Который регистрируется в Init() Метод.В методе PipeMessage нет регистрации, которая, кажется, вообще не достигается.

Если я создаю решение для amd64 и развертываю его на виртуальной машине, все работает должным образом.

Есть ли способ заставить его работать на Raspberry Pi с Raspian?

Кстати: я также попробовал Функции Azure C # Шаблон модуля.Тот же результат: на amd64 это работает, но на arm32 это не так.

ОБНОВЛЕНИЕ: Вот регистрация edgeAgent :

            █████╗ ███████╗██╗   ██╗██████╗ ███████╗
       ██╔══██╗╚══███╔╝██║   ██║██╔══██╗██╔════╝
       ███████║  ███╔╝ ██║   ██║██████╔╝█████╗
       ██╔══██║ ███╔╝  ██║   ██║██╔══██╗██╔══╝
       ██║  ██║███████╗╚██████╔╝██║  ██║███████╗
       ╚═╝  ╚═╝╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚══════╝

 ██╗ ██████╗ ████████╗    ███████╗██████╗  ██████╗ ███████╗
 ██║██╔═══██╗╚══██╔══╝    ██╔════╝██╔══██╗██╔════╝ ██╔════╝
 ██║██║   ██║   ██║       █████╗  ██║  ██║██║  ███╗█████╗
 ██║██║   ██║   ██║       ██╔══╝  ██║  ██║██║   ██║██╔══╝
 ██║╚██████╔╝   ██║       ███████╗██████╔╝╚██████╔╝███████╗
 ╚═╝ ╚═════╝    ╚═╝       ╚══════╝╚═════╝  ╚═════╝ ╚══════╝

2018-12-21 07:08:27.323 +00:00 [INF] - Edge agent attempting to connect to IoT Hub via Amqp_Tcp_Only...
2018-12-21 07:08:31.986 +00:00 [INF] - Created persistent store at /tmp/edgeAgent
2018-12-21 07:08:34.193 +00:00 [INF] - Edge agent connected to IoT Hub via Amqp_Tcp_Only.
2018-12-21 07:08:37.624 +00:00 [INF] - Plan execution started for deployment 8
2018-12-21 07:08:37.654 +00:00 [INF] - Executing command: "Stop module SampleModule"
2018-12-21 07:08:37.766 +00:00 [INF] - Executing command: "Remove module SampleModule"
2018-12-21 07:08:37.964 +00:00 [INF] - Executing command: "Saving SampleModule to store"
2018-12-21 07:08:38.141 +00:00 [INF] - Executing command: "Command Group: (
  [Create module SampleModule2]
  [Start module SampleModule2]
)"
2018-12-21 07:08:38.152 +00:00 [INF] - Executing command: "Create module SampleModule2"
2018-12-21 07:08:42.678 +00:00 [INF] - Executing command: "Start module SampleModule2"
2018-12-21 07:08:45.749 +00:00 [INF] - Executing command: "Command Group: (
  [Stop module tempSensor]
  [Start module tempSensor]
  [Saving tempSensor to store]
)"
2018-12-21 07:08:45.750 +00:00 [INF] - Executing command: "Stop module tempSensor"
2018-12-21 07:08:45.759 +00:00 [INF] - Executing command: "Start module tempSensor"
2018-12-21 07:08:48.423 +00:00 [INF] - Executing command: "Saving tempSensor to store"
2018-12-21 07:08:48.491 +00:00 [INF] - Executing command: "Command Group: (
  [Stop module edgeHub]
  [Start module edgeHub]
  [Saving edgeHub to store]
)"
2018-12-21 07:08:48.491 +00:00 [INF] - Executing command: "Stop module edgeHub"
2018-12-21 07:08:48.501 +00:00 [INF] - Executing command: "Start module edgeHub"
2018-12-21 07:08:51.895 +00:00 [INF] - Executing command: "Saving edgeHub to store"
2018-12-21 07:08:51.900 +00:00 [INF] - Plan execution ended for deployment 8
2018-12-21 07:08:52.743 +00:00 [INF] - Updated reported properties
2018-12-21 07:08:57.811 +00:00 [INF] - HealthRestartPlanner is clearing restart stats for module 'tempSensor' as it has been running healthy for 00:10:00.
2018-12-21 07:08:57.814 +00:00 [INF] - HealthRestartPlanner is clearing restart stats for module 'edgeHub' as it has been running healthy for 00:10:00.
2018-12-21 07:08:57.815 +00:00 [INF] - Plan execution started for deployment 8
2018-12-21 07:08:57.818 +00:00 [INF] - Executing command: "Saving tempSensor to store"
2018-12-21 07:08:57.819 +00:00 [INF] - Executing command: "Saving edgeHub to store"
2018-12-21 07:08:57.820 +00:00 [INF] - Plan execution ended for deployment 8
2018-12-21 07:08:58.038 +00:00 [INF] - Updated reported properties
2018-12-21 07:09:03.239 +00:00 [INF] - Updated reported properties

А вот некоторые записииз edgeHub (их намного больше, но, похоже, все те же исключения):

2018-12-21 07:28:23.450 +00:00 [WRN] - Error sending messages to module bewaPi1/SampleModule2
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at DotNetty.Buffers.HeapArena.NewChunk(Int32 pageSize, Int32 maxOrder, Int32 pageShifts, Int32 chunkSize)
   at DotNetty.Buffers.PoolArena`1.AllocateNormal(PooledByteBuffer`1 buf, Int32 reqCapacity, Int32 normCapacity)
   at DotNetty.Buffers.PoolArena`1.Allocate(PoolThreadCache`1 cache, PooledByteBuffer`1 buf, Int32 reqCapacity)
   at DotNetty.Buffers.PooledByteBufferAllocator.NewHeapBuffer(Int32 initialCapacity, Int32 maxCapacity)
   at DotNetty.Buffers.AbstractByteBufferAllocator.Buffer(Int32 initialCapacity, Int32 maxCapacity)
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ByteBufferConverter.ToByteBuffer(Byte[] bytes) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ByteBufferConverter.cs:line 39
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ProtocolGatewayMessageConverter.FromMessage(IMessage message) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ProtocolGatewayMessageConverter.cs:line 101
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.DeviceProxy.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceProxy.cs:line 73
   at Microsoft.Azure.Devices.Edge.Hub.Core.Device.DeviceMessageHandler.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/device/DeviceMessageHandler.cs:line 256
   at Microsoft.Azure.Devices.Edge.Hub.Core.Routing.ModuleEndpoint.ModuleMessageProcessor.<>c__DisplayClass5_2.<<ProcessAsync>b__0>d.MoveNext() in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/routing/ModuleEndpoint.cs:line 98
2018-12-21 07:28:28.517 +00:00 [WRN] - Non retryable exception occurred while sending message.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at DotNetty.Buffers.HeapArena.NewChunk(Int32 pageSize, Int32 maxOrder, Int32 pageShifts, Int32 chunkSize)
   at DotNetty.Buffers.PoolArena`1.AllocateNormal(PooledByteBuffer`1 buf, Int32 reqCapacity, Int32 normCapacity)
   at DotNetty.Buffers.PoolArena`1.Allocate(PoolThreadCache`1 cache, PooledByteBuffer`1 buf, Int32 reqCapacity)
   at DotNetty.Buffers.PooledByteBufferAllocator.NewHeapBuffer(Int32 initialCapacity, Int32 maxCapacity)
   at DotNetty.Buffers.AbstractByteBufferAllocator.Buffer(Int32 initialCapacity, Int32 maxCapacity)
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ByteBufferConverter.ToByteBuffer(Byte[] bytes) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ByteBufferConverter.cs:line 39
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ProtocolGatewayMessageConverter.FromMessage(IMessage message) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ProtocolGatewayMessageConverter.cs:line 101
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.DeviceProxy.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceProxy.cs:line 73
   at Microsoft.Azure.Devices.Edge.Hub.Core.Device.DeviceMessageHandler.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/device/DeviceMessageHandler.cs:line 256
   at Microsoft.Azure.Devices.Edge.Hub.Core.Routing.ModuleEndpoint.ModuleMessageProcessor.<>c__DisplayClass5_2.<<ProcessAsync>b__0>d.MoveNext() in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/routing/ModuleEndpoint.cs:line 98
2018-12-21 07:28:28.521 +00:00 [WRN] - Error sending messages to module bewaPi1/SampleModule2
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at DotNetty.Buffers.HeapArena.NewChunk(Int32 pageSize, Int32 maxOrder, Int32 pageShifts, Int32 chunkSize)
   at DotNetty.Buffers.PoolArena`1.AllocateNormal(PooledByteBuffer`1 buf, Int32 reqCapacity, Int32 normCapacity)
   at DotNetty.Buffers.PoolArena`1.Allocate(PoolThreadCache`1 cache, PooledByteBuffer`1 buf, Int32 reqCapacity)
   at DotNetty.Buffers.PooledByteBufferAllocator.NewHeapBuffer(Int32 initialCapacity, Int32 maxCapacity)
   at DotNetty.Buffers.AbstractByteBufferAllocator.Buffer(Int32 initialCapacity, Int32 maxCapacity)
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ByteBufferConverter.ToByteBuffer(Byte[] bytes) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ByteBufferConverter.cs:line 39
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ProtocolGatewayMessageConverter.FromMessage(IMessage message) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ProtocolGatewayMessageConverter.cs:line 101
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.DeviceProxy.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceProxy.cs:line 73
   at Microsoft.Azure.Devices.Edge.Hub.Core.Device.DeviceMessageHandler.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/device/DeviceMessageHandler.cs:line 256
   at Microsoft.Azure.Devices.Edge.Hub.Core.Routing.ModuleEndpoint.ModuleMessageProcessor.<>c__DisplayClass5_2.<<ProcessAsync>b__0>d.MoveNext() in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/routing/ModuleEndpoint.cs:line 98
2018-12-21 07:28:33.666 +00:00 [WRN] - Non retryable exception occurred while sending message.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at DotNetty.Buffers.HeapArena.NewChunk(Int32 pageSize, Int32 maxOrder, Int32 pageShifts, Int32 chunkSize)
   at DotNetty.Buffers.PoolArena`1.AllocateNormal(PooledByteBuffer`1 buf, Int32 reqCapacity, Int32 normCapacity)
   at DotNetty.Buffers.PoolArena`1.Allocate(PoolThreadCache`1 cache, PooledByteBuffer`1 buf, Int32 reqCapacity)
   at DotNetty.Buffers.PooledByteBufferAllocator.NewHeapBuffer(Int32 initialCapacity, Int32 maxCapacity)
   at DotNetty.Buffers.AbstractByteBufferAllocator.Buffer(Int32 initialCapacity, Int32 maxCapacity)
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ByteBufferConverter.ToByteBuffer(Byte[] bytes) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ByteBufferConverter.cs:line 39
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ProtocolGatewayMessageConverter.FromMessage(IMessage message) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ProtocolGatewayMessageConverter.cs:line 101
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.DeviceProxy.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceProxy.cs:line 73
   at Microsoft.Azure.Devices.Edge.Hub.Core.Device.DeviceMessageHandler.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/device/DeviceMessageHandler.cs:line 256
   at Microsoft.Azure.Devices.Edge.Hub.Core.Routing.ModuleEndpoint.ModuleMessageProcessor.<>c__DisplayClass5_2.<<ProcessAsync>b__0>d.MoveNext() in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/routing/ModuleEndpoint.cs:line 98
2018-12-21 07:28:33.669 +00:00 [WRN] - Error sending messages to module bewaPi1/SampleModule2
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at DotNetty.Buffers.HeapArena.NewChunk(Int32 pageSize, Int32 maxOrder, Int32 pageShifts, Int32 chunkSize)
   at DotNetty.Buffers.PoolArena`1.AllocateNormal(PooledByteBuffer`1 buf, Int32 reqCapacity, Int32 normCapacity)
   at DotNetty.Buffers.PoolArena`1.Allocate(PoolThreadCache`1 cache, PooledByteBuffer`1 buf, Int32 reqCapacity)
   at DotNetty.Buffers.PooledByteBufferAllocator.NewHeapBuffer(Int32 initialCapacity, Int32 maxCapacity)
   at DotNetty.Buffers.AbstractByteBufferAllocator.Buffer(Int32 initialCapacity, Int32 maxCapacity)
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ByteBufferConverter.ToByteBuffer(Byte[] bytes) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ByteBufferConverter.cs:line 39
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ProtocolGatewayMessageConverter.FromMessage(IMessage message) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ProtocolGatewayMessageConverter.cs:line 101
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.DeviceProxy.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceProxy.cs:line 73
   at Microsoft.Azure.Devices.Edge.Hub.Core.Device.DeviceMessageHandler.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/device/DeviceMessageHandler.cs:line 256
   at Microsoft.Azure.Devices.Edge.Hub.Core.Routing.ModuleEndpoint.ModuleMessageProcessor.<>c__DisplayClass5_2.<<ProcessAsync>b__0>d.MoveNext() in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/routing/ModuleEndpoint.cs:line 98
2018-12-21 07:28:39.012 +00:00 [WRN] - Non retryable exception occurred while sending message.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at DotNetty.Buffers.HeapArena.NewChunk(Int32 pageSize, Int32 maxOrder, Int32 pageShifts, Int32 chunkSize)
   at DotNetty.Buffers.PoolArena`1.AllocateNormal(PooledByteBuffer`1 buf, Int32 reqCapacity, Int32 normCapacity)
   at DotNetty.Buffers.PoolArena`1.Allocate(PoolThreadCache`1 cache, PooledByteBuffer`1 buf, Int32 reqCapacity)
   at DotNetty.Buffers.PooledByteBufferAllocator.NewHeapBuffer(Int32 initialCapacity, Int32 maxCapacity)
   at DotNetty.Buffers.AbstractByteBufferAllocator.Buffer(Int32 initialCapacity, Int32 maxCapacity)
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ByteBufferConverter.ToByteBuffer(Byte[] bytes) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ByteBufferConverter.cs:line 39
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ProtocolGatewayMessageConverter.FromMessage(IMessage message) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ProtocolGatewayMessageConverter.cs:line 101
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.DeviceProxy.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceProxy.cs:line 73
   at Microsoft.Azure.Devices.Edge.Hub.Core.Device.DeviceMessageHandler.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/device/DeviceMessageHandler.cs:line 256
   at Microsoft.Azure.Devices.Edge.Hub.Core.Routing.ModuleEndpoint.ModuleMessageProcessor.<>c__DisplayClass5_2.<<ProcessAsync>b__0>d.MoveNext() in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/routing/ModuleEndpoint.cs:line 98
2018-12-21 07:28:39.015 +00:00 [WRN] - Error sending messages to module bewaPi1/SampleModule2
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at DotNetty.Buffers.HeapArena.NewChunk(Int32 pageSize, Int32 maxOrder, Int32 pageShifts, Int32 chunkSize)
   at DotNetty.Buffers.PoolArena`1.AllocateNormal(PooledByteBuffer`1 buf, Int32 reqCapacity, Int32 normCapacity)
   at DotNetty.Buffers.PoolArena`1.Allocate(PoolThreadCache`1 cache, PooledByteBuffer`1 buf, Int32 reqCapacity)
   at DotNetty.Buffers.PooledByteBufferAllocator.NewHeapBuffer(Int32 initialCapacity, Int32 maxCapacity)
   at DotNetty.Buffers.AbstractByteBufferAllocator.Buffer(Int32 initialCapacity, Int32 maxCapacity)
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ByteBufferConverter.ToByteBuffer(Byte[] bytes) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ByteBufferConverter.cs:line 39
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.ProtocolGatewayMessageConverter.FromMessage(IMessage message) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/ProtocolGatewayMessageConverter.cs:line 101
   at Microsoft.Azure.Devices.Edge.Hub.Mqtt.DeviceProxy.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Mqtt/DeviceProxy.cs:line 73
   at Microsoft.Azure.Devices.Edge.Hub.Core.Device.DeviceMessageHandler.SendMessageAsync(IMessage message, String input) in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/device/DeviceMessageHandler.cs:line 256
   at Microsoft.Azure.Devices.Edge.Hub.Core.Routing.ModuleEndpoint.ModuleMessageProcessor.<>c__DisplayClass5_2.<<ProcessAsync>b__0>d.MoveNext() in /home/vsts/work/1/s/edge-hub/src/Microsoft.Azure.Devices.Edge.Hub.Core/routing/ModuleEndpoint.cs:line 98

Таким образом, проблема вызвана System.OutOfMemoryExceptions.Но что вызывает эти исключения?

Update2 : Это, кажется, известная проблема (см. здесь ), и ее можно решить, установив OptimizeForPerformance до ложь .Я попробую это и посмотрю, работает ли он.

Ответы [ 2 ]

0 голосов
/ 21 декабря 2018

Маршрутизация сообщений между модулями не работает из-за исключений System.OutOfMemoryException в модуле edgeHub.Проблема описана и обсуждена здесь .

Microsoft внедрила решение, которое описано здесь .

Вкратце: если IotEdge Solutions работает наRaspberry Pi переменная окружения OptimizeForPerformance должна быть установлена ​​на false .

0 голосов
/ 21 декабря 2018

Кажется, проблема связана с https://docs.microsoft.com/en-us/azure/iot-edge/troubleshoot#stability-issues-on-resource-constrained-devices

Пожалуйста, перейдите по ссылке и отключите OptimizeForPerformance в манифесте развертывания.

...