QBoard » Supporting Tech Stack » IOT » What protocol does Azure IoT hub use?

What protocol does Azure IoT hub use?

  • What protocol does Azure IoT hub use?
      August 21, 2021 5:37 PM IST
    0
    • Cloud-to-device pattern. HTTPS does not have an efficient way to implement server push. As such, when you are using HTTPS, devices poll IoT Hub for cloud-to-device messages. This approach is inefficient for both the device and IoT Hub. Under current HTTPS guidelines, each device should poll for messages every 25 minutes or more. Issuing more HTTPS receives results in IoT Hub throttling the requests. MQTT and AMQP support server push when receiving cloud-to-device messages. They enable immediate pushes of messages from IoT Hub to the device. If delivery latency is a concern, MQTT or AMQP are the best protocols to use. For rarely connected devices, HTTPS works as well.

    • Field gateways. MQTT and HTTPS support only a single device identity (device ID plus credentials) per TLS connection. For this reason, these protocols are not supported for field gateway scenarios that require multiplexing messages using multiple device identities across a single or a pool of upstream connections to IoT Hub. Such gateways can use a protocol that supports multiple device identities per connection, like AMQP, for their upstream traffic.

      October 14, 2021 12:58 PM IST
    0
  • The Azure IoT protocol gateway is a framework for protocol adaptation that is designed for high-scale, bidirectional device communication with IoT Hub. The protocol gateway is a pass-through component that accepts device connections over a specific protocol. It bridges the traffic to IoT Hub over AMQP 1.0.

    You can deploy the protocol gateway in Azure in a highly scalable way by using Azure Service Fabric, Azure Cloud Services worker roles, or Windows Virtual Machines. In addition, the protocol gateway can be deployed in on-premises environments, such as field gateways.

    The Azure IoT protocol gateway includes an MQTT protocol adapter that enables you to customize the MQTT protocol behavior if necessary. Since IoT Hub provides built-in support for the MQTT v3.1.1 protocol, you should only consider using the MQTT protocol adapter if protocol customizations or specific requirements for additional functionality are required.

    The MQTT adapter also demonstrates the programming model for building protocol adapters for other protocols. In addition, the Azure IoT protocol gateway programming model allows you to plug in custom components for specialized processing such as custom authentication, message transformations, compression/decompression, or encryption/decryption of traffic between the devices and IoT Hub.

    For flexibility, the Azure IoT protocol gateway and MQTT implementation are provided in an open-source software project. You can use the open-source project to add support for various protocols and protocol versions, or customize the implementation for your scenario.

      October 19, 2021 2:51 PM IST
    0
  • The question is which protocols your devices support and how configurable your devices are. For instance you might be able to talk MQTT directly to the IoT Hub without using the SDK: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support#using-the-mqtt-protocol-directly-as-a-device

    Same is possible for HTTP using the REST API directly: https://docs.microsoft.com/en-us/rest/api/iothub/device

    If neither is an option then yes, you need some kind of gateway - like in the examples which you linked.

      September 13, 2021 1:22 PM IST
    0
  • IoT Hub allows devices to use the following protocols for device-side communications:

    • MQTT
    • MQTT over WebSockets
    • AMQP
    • AMQP over WebSockets
    • HTTPS

    For information about how these protocols support specific IoT Hub features, see Device-to-cloud communications guidance and Cloud-to-device communications guidance.

    The following table provides the high-level recommendations for your choice of protocol:

    TABLE 1
    Protocol When you should choose this protocol
    MQTT
    MQTT over WebSocket
    Use on all devices that do not require to connect multiple devices (each with its own per-device credentials) over the same TLS connection.
    AMQP
    AMQP over WebSocket
    Use on field and cloud gateways to take advantage of connection multiplexing across devices.
    HTTPS Use for devices that cannot support other protocols.

    Consider the following points when you choose your protocol for device-side communications:

    • Cloud-to-device pattern. HTTPS does not have an efficient way to implement server push. As such, when you are using HTTPS, devices poll IoT Hub for cloud-to-device messages. This approach is inefficient for both the device and IoT Hub. Under current HTTPS guidelines, each device should poll for messages every 25 minutes or more. Issuing more HTTPS receives results in IoT Hub throttling the requests. MQTT and AMQP support server push when receiving cloud-to-device messages. They enable immediate pushes of messages from IoT Hub to the device. If delivery latency is a concern, MQTT or AMQP are the best protocols to use. For rarely connected devices, HTTPS works as well.

    • Field gateways. MQTT and HTTPS support only a single device identity (device ID plus credentials) per TLS connection. For this reason, these protocols are not supported for field gateway scenarios that require multiplexing messages using multiple device identities across a single or a pool of upstream connections to IoT Hub. Such gateways can use a protocol that supports multiple device identities per connection, like AMQP, for their upstream traffic.

    • Low resource devices. The MQTT and HTTPS libraries have a smaller footprint than the AMQP libraries. As such, if the device has limited resources (for example, less than 1-MB RAM), these protocols might be the only protocol implementation available.

    • Network traversal. The standard AMQP protocol uses port 5671, and MQTT listens on port 8883. Use of these ports could cause problems in networks that are closed to non-HTTPS protocols. Use MQTT over WebSockets, AMQP over WebSockets, or HTTPS in this scenario.

    • Payload size. MQTT and AMQP are binary protocols, which result in more compact payloads than HTTPS.

     Warning

    When using HTTPS, each device should poll for cloud-to-device messages no more than once every 25 minutes. In development, each device can poll more frequently, if desired.

     Important

    The following functionality for devices that use X.509 certificate authority (CA) authentication is not yet generally available, and preview mode must be enabled:

    • HTTPS, MQTT over WebSockets, and AMQP over WebSockets protocols.
    • File uploads (all protocols).

    It is generally available on devices that use X.509 thumbprint authentication. To learn more about X.509 authentication with IoT Hub, see Supported X.509 certificates.

    Port numbers

    Devices can communicate with IoT Hub in Azure using various protocols. Typically, the choice of protocol is driven by the specific requirements of the solution. The following table lists the outbound ports that must be open for a device to be able to use a specific protocol:

    PORT NUMBERS
    Protocol Port
    MQTT 8883
    MQTT over WebSockets 443
    AMQP 5671
    AMQP over WebSockets 443
    HTTPS 443

    Once you have created an IoT hub in an Azure region, the IoT hub keeps the same IP address for the lifetime of that IoT hub. However, if Microsoft moves the IoT hub to a different scale unit to maintain quality of service, then it is assigned a new IP address.

      September 14, 2021 1:19 PM IST
    0