Azure / azure-iot-explorer

Cross-platform UI for interacting with devices attached to Azure IoT Hub. This tool is meant for learning and testing, not for production environment.
MIT License
223 stars 72 forks source link

[BUG] Enqueued time is interpreted as a number instead of a datetime value #558

Closed murdockcrc closed 1 year ago

murdockcrc commented 1 year ago

Describe the bug When getting telemetry messages from an IoT Edge device using the IoT Hub Explorer, the system properties are represented like this:

"systemProperties": {
    "iothub-connection-device-id": "xxx-dev-edge-001",
    "iothub-connection-auth-method": "{\"scope\":\"device\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}",
    "iothub-connection-auth-generation-id": "637678139892935630",
    "iothub-enqueuedtime": 1664776274356,
    "iothub-message-source": "Telemetry",
    "x-opt-sequence-number": 5733994,
    "x-opt-offset": "1017928807456",
    "x-opt-enqueued-time": 1664776274418
  }

The property iothub-enqueuedtime is serialized as a number.

I believe this is incorrect, as per the documentation, the value of iothub-enqueuedtime should be a datetime object. From the docs:

iothub-enqueuedtime | Date and time the Device-to-Cloud message was received by IoT Hub.

If you connect a console app to the event hub compatible endpoint, and read the raw messages from there, you will see that this property is serialized as a datetimeoffset value:

partitionEvent.Data.SystemProperties["iothub-enqueuedtime"].ToString;
// Produces the following output:
10/03/2022 05:56:05

It seems to me that the value of this datetime object is serialized by the IoT Hub Explorer as a number, whereas the source of data is a datetime object.

Expected behavior The telemetry data preserves its original data type.

Additional context Running version 0.15.0

YingXue commented 1 year ago

Hi @murdockcrc We looked into the issue. The short answer is, Explorer does not modify any system properties, we show them as is. The x-opt-enqueued-time is directly surfaced by the event hub node sdk that we uses, and here it what they return for example image We were wondering if it is sufficent for your use case to use this enqueueTime property directly, which is not in system properties: image If not, please let us know, and we will reopen the bug and route it to the event hub node sdk team.