Azure / azure-iot-sdk-csharp

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

[Bug Report] InvokeDeviceMethodAsync fails with error code 400000 #3472

Open williamiwell opened 6 days ago

williamiwell commented 6 days ago

Context

Description of the issue

We use IotHub to send messages from our cloud to edge devices, using the InvokeDeviceMethodAsync method. This worked fine until 25-September-2024 19:00 UTC, but now we receive error code 400000. We can't find any information about this code, it's not listed in the common error codes docs.

We are using the latests nuget package: microsoft.azure.devices/1.39.1. The devices are online and are able to send device to cloud messages.

Any idea what is going on and if we can resolve this or that is related to an IotEdge issue? Our IotHub is located in West Europa.

Code sample exhibiting the issue

var serviceClient = iotHubFactory.CreateServiceClient();
response = await serviceClient.InvokeDeviceMethodAsync(moduleId, cloudToDeviceMethod);

this throws the exception below:

{"Message":"{\"errorCode\":400000,\"message\":\"400\",\"trackingId\":\"46A2268BA66A4093B44234E2B56A6464-G2:-TimeStamp:2024-09-26T07:52:28.960569771Z\",\"timestampUtc\":\"2024-09-26T07:52:28.960569771Z\",\"info\":null}","ExceptionMessage":""}
timtay-microsoft commented 6 days ago

Can you share a bit more about the direct method payload you are sending?

williamiwell commented 6 days ago

The payload is a json with protobuf base64 string, for example

{ "byteArrayBase64": "CiENAAB6RBIMCPKt1rcGEKiz05sBGgwIrq7WtwYQqLPTmwE=" }

The code below is used to set the payload:

var payloadJson = JsonConvert.SerializeObject(payload, jsonSerializerSettings); cloudToDeviceMethod.SetPayloadJson(payloadJson);