Search code examples
pythonazureazure-iot-hubazure-iot-sdk

Cannot send message to Azure IoT Hub to units with ":" in their device id


I am trying to send messages from my machine to a IoT-Hub. I am using the following code:

    message = Message('{{"temperature": 20,"humidity": 10}}')
    client = IoTHubDeviceClient.create_from_connection_string(CONNECTION_STRING)
    client.send_message(message)

This works when the deviceId in CONNECTION_STRING doesn't have colons in it.

CONNECTION_STRING = "HostName=my-iot-hub.azure-devices.net;DeviceId=E0:DC:A0:73:C6:C3;SharedAccessKey=password"


CONNECTION_STRING = "HostName=my-iot-hub.azure-devices.net;DeviceId=my_device;SharedAccessKey=password"

The first connectionstring doesn't work. The process hangs when trying to send the message - but doesn't give me an error message. The second sends without any problems.

Is there some way to escape the colons?


Solution

  • We confirmed this is a bug with url encoding. In the next release of azure-iot-device (releases higher than 2.3.0), we will be adding a fix.

    Thanks.