from my Azure IoT Edge module (FROM /message/modules/<MODULE>/outputs/<OUTPUT>)
via edgeHub
to the Azure IoT Hub (INTO $upstream)
Message creation & sending:
// e.g. "2024-05-23T07:50:52.598Z"
const now = new Date().toISOString();
const message = new Message(JSON.stringify(data));
message.properties.add('iothub-creation-time-utc', now);
client.sendOutputEvent(output, message);
This works fine when module uses MQTT protocol to connect to edgeHub:
import { Mqtt } from 'azure-iot-device-mqtt'
import { ModuleClient } from 'azure-iot-device'
client = await ModuleClient.fromEnvironment(Mqtt)
Current Behavior
When I switch the module from MQTT to AMQP protocol (NOTE: no other changes to the code!):
import { Amqp } from 'azure-iot-device-amqp'
import { ModuleClient } from 'azure-iot-device'
client = await ModuleClient.fromEnvironment(Amqp)
then messages are no longer routed from the Azure IoT Edge device to the Azure IoT Hub.
Instead you can now see an exception in edgeHub log, f.ex.
System.FormatException: String '2024-05-23T07:50:52.598Z' was not recognized as a valid DateTime.
if (inputMessage.SystemProperties.TryGetNonEmptyValue(SystemProperties.CreationTime, out string creationTime))
{
message.CreationTimeUtc = DateTime.ParseExact(creationTime, "o", CultureInfo.InvariantCulture);
}
The "o" format in the above line only seems to accept YYYY-MM-DDTHH:MM:SS.1234567Z as valid. I confirmed this by applying the following workaround to my code:
With the workaround in place the errors disappeared from the log and messages were routed again from the Azure IoT Edge device to the Azure IoT Hub.
Steps to Reproduce
create an Azure IoT Edge device
create a custom module with AMQP as protocol
see the code snippets in the above description for the message creation
deploy custom module to Azure IoT Edge device
monitor events from the Azure IoT Edge device on the Azure IoT Hub
Context (Environment)
Device Information
Host OS: Debian GNU/Linux 12 (bookworm) (tailored build of Raspberry Pi OS)
Architecture: arm64
Container OS: Linux containers
Runtime Versions
aziot-edged: 1.5.0
Edge Agent: 1.5
Edge Hub: 1.5
Docker/Moby: 26.1.2
Additional Information
What is the intention behind the strict DateTime.ParseExact(..., "o", ...) ("The round-trip ("O", "o") format specifier" according to .NET documentation)? It should accept any valid UTC ISO-8601 string.
Expected Behavior
I follow the System Properties of D2C IoT messages table and add a creation time property to event messages. Those messages will be routed
FROM /message/modules/<MODULE>/outputs/<OUTPUT>
)edgeHub
INTO $upstream
)Message creation & sending:
This works fine when module uses
MQTT
protocol to connect toedgeHub
:Current Behavior
When I switch the module from
MQTT
toAMQP
protocol (NOTE: no other changes to the code!):then messages are no longer routed from the Azure IoT Edge device to the Azure IoT Hub.
Instead you can now see an exception in
edgeHub
log, f.ex.The traceback points to this line in the
edgeHub
source code in DeviceClientMessageConverter.cs:The
"o"
format in the above line only seems to acceptYYYY-MM-DDTHH:MM:SS.1234567Z
as valid. I confirmed this by applying the following workaround to my code:With the workaround in place the errors disappeared from the log and messages were routed again from the Azure IoT Edge device to the Azure IoT Hub.
Steps to Reproduce
Context (Environment)
Device Information
Debian GNU/Linux 12 (bookworm)
(tailored build of Raspberry Pi OS)arm64
Runtime Versions
1.5.0
1.5
1.5
26.1.2
Additional Information
What is the intention behind the strict
DateTime.ParseExact(..., "o", ...)
("The round-trip ("O", "o") format specifier" according to .NET documentation)? It should accept any valid UTC ISO-8601 string.