Search code examples
azurehttpsmqttazure-iot-hubnb-iot

Azure IoT Hub MQTT username and password character length limitation


I am trying to get data into Azure Iot-Hub using a SARA-R410-02B module (NB-IoT) via MQTT or HTTPS. Microsofts MQTT guide for IoT-Hub states that:

  • For the Username field, use {iothubhostname}/{device_id}/?api-version=2018-06-30, where {iothubhostname} is the full CName of the IoT hub.

    For example, if the name of your IoT hub is contoso.azure-devices.net and if the name of your device is MyDevice01, the full Username field should contain: contoso.azure-devices.net/MyDevice01/?api-version=2018-06-30

  • For the Password field, use a SAS token. The format of the SAS token is the same as for both the HTTPS and AMQP protocols:

    SharedAccessSignature sig={signature-string}&se={expiry}&sr={URL-encoded-resourceURI}

This means that the username (and password) will exceed the 30-character limitation that i have on the SARA-R410. Is there any way around this? I have the same limitation when it comes to HTTPS.

I have found that the password limitation can be solved by using x.509 certificates, but the username remain the same.


Solution

  • I´ve tried without the api parameter for the HTTP, and it does not work. I have some problems with coverage, so i still haven't tried with MQTT, but I am guessing that the result will be the same?

    I got an answer from u-blox. They say it can be worked around by implementing the MQTT protocol using sockets on the SARA-R410. This seems like the best solution.