Skip to content

Commit 8b55656

Browse files
committed
Add info to use MQTT-WS if MQTT port is blocked. GH issue 45893 and 39536
1 parent a73b489 commit 8b55656

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ 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+
```node.js
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+
```
48+
3149
## Using the device SDKs
3250

3351
[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.

articles/iot-hub/quickstart-send-telemetry-dotnet.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ az extension add --name azure-cli-iot-ext
4545

4646
Download the Azure IoT C# samples from https://github.com/Azure-Samples/azure-iot-samples-csharp/archive/master.zip and extract the ZIP archive.
4747

48+
Make sure that port 8883 is open in your firewall. The sample in this quickstart uses MQTT protocol, which communicates over port 8883. This port may be blocked in some corporate and educational network environments. For more information and ways to work-around this issue, see [Connecting to IoT Hub (MQTT)](iot-hub-mqtt-support.md#connecting-to-iot-hub).
49+
4850
## Create an IoT hub
4951

5052
[!INCLUDE [iot-hub-include-create-hub](../../includes/iot-hub-include-create-hub.md)]

0 commit comments

Comments
 (0)