Azure / azure-iot-sdk-csharp

A C# SDK for connecting devices to Microsoft Azure IoT services
Other
457 stars 493 forks source link

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

Closed wischi-chr closed 3 weeks ago

wischi-chr commented 4 months ago

Context

Context is very likely irrelevant

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.

https://github.com/Azure/azure-iot-sdk-csharp/blob/9e445ce1e817c225758d7a351974848b7259788c/iothub/device/src/InternalClient.cs#L1573

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

timtay-microsoft commented 4 months ago

3441 should fix this for you

wischi-chr commented 3 weeks ago

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

Thanks for fixing it.