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
224 stars 73 forks source link

[BUG] "application" is not included only when using Azure IoT Explorer #511

Closed makoto-soracom closed 2 years ago

makoto-soracom commented 2 years ago

Describe the bug When using Azure CLI, there is "application" key in the "properties".

$ az iot hub monitor-events -g {resource_group} -n {iot_hub} --props app
Starting event monitor, use ctrl-c to stop...
{
    "event": {
        "origin": "myDevice-2950xxxxxxxxxxx",
        "module": "",
        "interface": "",
        "component": "",
        "properties": {
            "application": { <----- HERE
                "test": "1234567890"
            }
        },
        "payload": "{\"message\": \"Hello!\"}"
    }
}

When using Azure IoT Explorer, the "application" key doesn't exist.

{
  "body": {
    "message": "Hello!"
  },
  "enqueuedTime": "Wed Jul 06 2022 15:34:40 GMT+0900 (Japan Standard Time)",
  "properties": {
    "test": "1234567890" <----- HERE: The "application" key doesn't exist.
  }
}

To Reproduce Sent data from device as follows:

$ mosquitto_pub -d -q 1 --capath //etc/ssl/certs -V mqttv311 -p 8883 -h {iot_hub}.azure-devices.net -i myDevice-2950xxxxxxxxxxx -u "{iot_hub}.azure-devices.net/myDevice-2950xxxxxxxxxxx/api-version=2018-06-30" -P "SharedAccessSignature sr={iot_hub}.azure-devices.net&sig=xxxxx&se=12345&skn=iothubowner" -t "devices/myDevice-2950xxxxxxxxxxx/messages/events/test=1234567890" -m '{"message": "Hello!"}'

Expected behavior

{
  "body": {
    "message": "Hello!"
  },
  "enqueuedTime": "Wed Jul 06 2022 15:34:40 GMT+0900 (Japan Standard Time)",
  "properties": {
    "application": {
      "test": "1234567890"
    }
  }
}

Desktop (please complete the following information):

YingXue commented 2 years ago

Hi @makoto-soracom Can you share the way you added the property to the devices? It will be great if you can also use CLI to add properties, so it can help eliminate user errors. I am providing an example as below: az iot device simulate --device-id test1 --login "" --properties 'application={"test": "12345"}' And I am able to get the telemetry as expected from Explorer as image

In the code, we use Azure Event Hub's SDK, and grab the properties as is without any modification, where CLI does not. So in certain cases, it is possible it may show results differently but we don't really have control over it.

makoto-soracom commented 2 years ago

Thank you for your response!

My command is here as previous message:

mosquitto_pub -d -q 1 --capath //etc/ssl/certs -V mqttv311 -p 8883 -h {iot_hub}.azure-devices.net -i myDevice-2950xxxxxxxxxxx -u "{iot_hub}.azure-devices.net/myDevice-2950xxxxxxxxxxx/api-version=2018-06-30" -P "SharedAccessSignature sr={iot_hub}.azure-devices.net&sig=xxxxx&se=12345&skn=iothubowner" -t "devices/myDevice-2950xxxxxxxxxxx/messages/events/test=1234567890" -m '{"message": "Hello!"}'

Do I need to setapplication at some where in my command for Azure IoT Explorer?

Azure CLI can get the message as expected as:

{
    "event": {
        "origin": "myDevice-2950xxxxxxxxxxx",
        "module": "",
        "interface": "",
        "component": "",
        "properties": {
            "application": { <----- HERE
                "test": "1234567890"
            }
        },
        "payload": "{\"message\": \"Hello!\"}"
    }
}
YingXue commented 2 years ago

I don't think you will need to set anything, and from the command I've only see -m with 'Hello' as message body but no properties being specifically set, so I cannot tell how the properties are formatted. I am wondering if this is a system property. Can you try check 'Show system properties' checkbox on the top and see if there is anything showing as you're expecting? image

Also we released our latest version 0.14.10 to address another issue which changed the Event hub SDK. Please feel free to check it out and see if that helped with issue or not.

YingXue commented 2 years ago

Hi, Please let us know if there's anything else we can help with. For now we will close the issue unless there is no information provided.

makoto-soracom commented 2 years ago

Hi, sorry for late response.

If I checked "Show system properties", the result was not changed.

The issue is that "application" is not displayed in Azure IoT Explorer but Azure CLI

Expected in Azure IoT Explorer (as same as Azure CLI):

        "properties": {
            "application": {
                "test": "1234567890"
            }
        },

Azure IoT Explorer v0.14.10:

        "properties": {
            "test": "1234567890"
        },

Thank you

makoto-soracom commented 2 years ago

@YingXue Could you confirm my message, please?