Azure/azure-iot-sdk-csharp

[Bug Report] Send message in batch to multiple outputs using ModuleClient throws

wischi-chr opened this issue · 2 comments

Context

Context is very likely irrelevant

  • OS: Windows 10 Desktop x64
  • Application's .NET Target Framework : .net core 6
  • Device: Laptop
  • SDK version used: 1.42.2 (but also inspected the source of the latest main commit)

Description of the issue

The bug is almost exactly the same as described in #3201, but for me it happened with SendEventBatchAsync.

Sending a message to multiple outputs, or multiple times throws the following exception:
An item with the same key has already been added. Key: iothub-outputname

Looking at the source it seems that the fix (using the indexer to set the property) for #3201 was only applied to the SendEventAsync method. The method SendEventBatchAsync still uses .Add() and throws.

messagesList.ForEach(m => m.SystemProperties.Add(MessageSystemPropertyNames.OutputName, outputName));

Would be great to fix it there too, I'm currently using reflection to remove the key before I call the ModuleClient - which is obviously not very pretty :-/

Thanks in advance

#3441 should fix this for you

Was shipped with 1.42.3 (release notes here) so I'm closing the issue.

Thanks for fixing it.