Supported Brokers

Push agent with the MQTT protocol supports the following Brokers:

Broker

SSL

NO SSL

Mosquitto

Azure IoT Hub

X

Eclipse Mosquitto

Push agent supports the following modes of communication with a Mosquitto broker:

  • Anonymous: send and receive messages without authenticating with the broker;

  • Authenticated: send and receive messages once authenticated with username and password;

  • Secured: send and receive encrypted messages through SSL.

Once configured the broker for the desired mode, it is possibile to send messages. Port 1883 is only used for an anonymous/authenticated communication, however, port 8883 is used for a secured communication. Generally, the configuration of the broker can be adapted to your needs. In the configuration it is possibile to select the mode of communication and the port.

IoT Hub

Push agent for Iot Hub support only a secured mode. This consists of a client authentication through a SAS Token that is generated for each device that wants to send/receive messages from IoT Hub. The client authenticates using username and password, where:

  • username: e.g. contoso.azure-devices.net/MyDevice01/?api-version=2018-06-30

  • password: e.g. SharedAccessSignature sig={signature-string}&se={expiry}&sr={URL-encoded-resourceURI}

To generate a SAS Token you need to access the Azure portal to obtain the «IoT Hub connection string» as seen at https://devblogs.microsoft.com/iotdev/understand-different-connection-strings-in-azure-iot-hub/. After obtaining the «connection string», it is possibile to generate the token using two applications:

  • Device Explorer:

    1. Download Device explore from https://github.com/Azure/azure-iot-sdk-csharp/releases

    2. Install, run and insert the «IoT Hub connection string» in the relative field; press the «Update» button and go to the Management tab

    3. Create a device by clicking «Create» if a device has not been already created.

    4. Click the «SAS Token…» button

    5. Select the desired device ( if not already selected)

    6. Set the TTL (Days) to the number of days of the token’s validity

    7. Click on the «Generate» button

  • Azure IoT Explorer:

    1. Download Azure IoT Explorer from https://github.com/Azure/azure-iot-explorer/releases

    2. Install and run it and insert «IoT Hub connection string» in the suggested field and press «Connnect»

    3. Create a device by clicking “New” if a device has not been already created.

    4. Select the desired device

    5. Expand the «Connection string with SAS token» tab

    6. Select «Primary Key» as Symmetric key

    7. Set Expiration (minutes) to the token’s validity time in minutes

    8. Click on the «Generate» button

Use the generated token as illustrated above to comunicate with the broker.

For each client that wants to send/receive messages, a device must be created on IoT Hub. It is not possible for clients to use the same devices to send/receive data. In contrast of Mosquitto IoT Hub is not a generic broker so it does not allow the option to send and receive information on custom topics. In fact, a device can send/receive information only on specific topics of the device, these are:

  • send: devices/{deviceid}/messages/event/

  • receive: devices/{deviceid}/messages/devicebound/#

To verify sending and receiving messages, Device Explorer and Azure IoT Explorer offer the possibility of monitoring received messages and sending messages to the device.

See also

Riferimenti

Push Agent