Skip to content

Commit 6d6b255

Browse files
committed
ch-ch-ch-changes
1 parent e18fee3 commit 6d6b255

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

articles/iot-hub/iot-hub-mqtt-support.md

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,25 @@ A device can use the MQTT protocol to connect to an IoT hub using any of the fol
2828
* Libraries in the [Azure IoT SDKs](https://github.com/Azure/azure-iot-sdks).
2929
* The MQTT protocol directly.
3030

31-
MQTT protocol uses port 8883. This port is blocked in many corporate and educational networking environments. If you can't open port 8883 in your firewall, we recommend using MQTT over Web Sockets. MQTT over Web Sockets communicates over port 443, which is almost always open in networking environments. When using the Azure IoT SDKs, you typically specify the transport or protocol type in the call to create a client as in the following examples.
32-
33-
```csharp
34-
private static TransportType s_transportType = TransportType.Mqtt_WebSocket_Only;
35-
DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(s_deviceConnectionString, s_transportType);
36-
```
37-
38-
```javascript
39-
var Client = require('azure-iot-device').Client;
40-
var Protocol = require('azure-iot-device-mqtt').MqttWs;
41-
var client = Client.fromConnectionString(deviceConnectionString, Protocol);
42-
```
43-
44-
```python
45-
from azure.iot.device.aio import IoTHubDeviceClient
46-
device_client = IoTHubDeviceClient.create_from_connection_string(conn_str, websockets=True)
47-
```
31+
The MQTT port (8883) is blocked in many corporate and educational networking environments. If you can't open port 8883 in your firewall, we recommend using MQTT over Web Sockets. MQTT over Web Sockets communicates over port 443, which is almost always open in networking environments. To learn how to specify the MQTT protocol when using the Azure IoT SDKs, see [Using the device SDKs](#using-the-device-sdks).
4832

4933
## Using the device SDKs
5034

51-
[Device SDKs](https://github.com/Azure/azure-iot-sdks) that support the MQTT protocol are available for Java, Node.js, C, C#, and Python. The device SDKs use the standard IoT Hub connection string to establish a connection to an IoT hub. To use the MQTT protocol, the client protocol parameter must be set to **MQTT**. By default, the device SDKs connect to an IoT Hub with the **CleanSession** flag set to **0** and use **QoS 1** for message exchange with the IoT hub.
35+
[Device SDKs](https://github.com/Azure/azure-iot-sdks) that support the MQTT protocol are available for Java, Node.js, C, C#, and Python. The device SDKs use the standard IoT Hub connection string to establish a connection to an IoT hub. To use the MQTT protocol, the client protocol parameter must be set to **MQTT**. You can also specify MQTT over Web Sockets in the client protocol parameter. By default, the device SDKs connect to an IoT Hub with the **CleanSession** flag set to **0** and use **QoS 1** for message exchange with the IoT hub.
5236

5337
When a device is connected to an IoT hub, the device SDKs provide methods that enable the device to exchange messages with an IoT hub.
5438

55-
The following table contains links to code samples for each supported language and specifies the parameter to use to establish a connection to IoT Hub using the MQTT protocol.
39+
The following table contains links to code samples for each supported language and specifies the parameter to use to establish a connection to IoT Hub using the MQTT or the MQTT over Web Sockets protocol.
5640

57-
| Language | Protocol parameter |
58-
| --- | --- |
59-
| [Node.js](https://github.com/Azure/azure-iot-sdk-node/blob/master/device/samples/simple_sample_device.js) |azure-iot-device-mqtt |
60-
| [Java](https://github.com/Azure/azure-iot-sdk-java/blob/master/device/iot-device-samples/send-receive-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/SendReceive.java) |IotHubClientProtocol.MQTT |
61-
| [C](https://github.com/Azure/azure-iot-sdk-c/tree/master/iothub_client/samples/iothub_client_sample_mqtt_dm) |MQTT_Protocol |
62-
| [C#](https://github.com/Azure/azure-iot-sdk-csharp/tree/master/iothub/device/samples) |TransportType.Mqtt |
63-
| [Python](https://github.com/Azure/azure-iot-sdk-python/tree/master/azure-iot-device/samples) |Always supports MQTT by default |
41+
| Language | MQTT protocol parameter | MQTT over Web Sockets protocol parameter
42+
| --- | --- | --- |
43+
| [Node.js](https://github.com/Azure/azure-iot-sdk-node/blob/master/device/samples/simple_sample_device.js) | azure-iot-device-mqtt.Mqtt | azure-iot-device-mqtt.MqttWs |
44+
| [Java](https://github.com/Azure/azure-iot-sdk-java/blob/master/device/iot-device-samples/send-receive-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/SendReceive.java) |IotHubClientProtocol.MQTT | IotHubClientProtocol.MQTT_WS |
45+
| [C](https://github.com/Azure/azure-iot-sdk-c/tree/master/iothub_client/samples/iothub_client_sample_mqtt_dm) | MQTT_Protocol | MQTT_WebSocket_Protocol |
46+
| [C#](https://github.com/Azure/azure-iot-sdk-csharp/tree/master/iothub/device/samples) | TransportType.Mqtt | TransportType.Mqtt falls back to MQTT over Web Sockets if MQTT fails. To specify MQTT over Web Sockets only, use TransportType.Mqtt_WebSocket_Only |
47+
| [Python](https://github.com/Azure/azure-iot-sdk-python/tree/master/azure-iot-device/samples) | Supports MQTT by default | Add `websockets=True` in the call to create the client |
6448

65-
### Default keep-alive timeout
49+
### Default keep-alive timeout
6650

6751
In order to ensure a client/IoT Hub connection stays alive, both the service and the client regularly send a *keep-alive* ping to each other. The client using IoT SDK sends a keep-alive at the interval defined in this table below:
6852

0 commit comments

Comments
 (0)