You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-hub/iot-hub-mqtt-support.md
+19-4Lines changed: 19 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ A device can use the MQTT protocol to connect to an IoT hub using any of the fol
28
28
* Libraries in the [Azure IoT SDKs](https://github.com/Azure/azure-iot-sdks).
29
29
* The MQTT protocol directly.
30
30
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).
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 and MQTT over Web Sockets protocols when using the Azure IoT SDKs, see [Using the device SDKs](#using-the-device-sdks).
32
32
33
33
## Using the device SDKs
34
34
@@ -41,11 +41,26 @@ The following table contains links to code samples for each supported language a
41
41
| Language | MQTT protocol parameter | MQTT over Web Sockets protocol parameter
|[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 |
|[C#](https://github.com/Azure/azure-iot-sdk-csharp/tree/master/iothub/device/samples)|[TransportType](https://docs.microsoft.com/dotnet/api/microsoft.azure.devices.client.transporttype?view=azure-dotnet).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
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 |
48
48
49
+
The following fragment shows how to specify the MQTT over Web Sockets protocol when using the Azure IoT Node.js SDK:
50
+
51
+
```javascript
52
+
var Client =require('azure-iot-device').Client;
53
+
var Protocol =require('azure-iot-device-mqtt').MqttWs;
54
+
var client =Client.fromConnectionString(deviceConnectionString, Protocol);
55
+
```
56
+
57
+
The following fragment shows how to specify the MQTT over Web Sockets protocol when using the Azure IoT Python SDK:
58
+
59
+
```python
60
+
from azure.iot.device.aio import IoTHubDeviceClient
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:
0 commit comments