简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM