Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ask, using AMPQP over WebSockets, to an IoT Hub to send a Cloud To Device message with the Azure IoT Hub Service API Python SDK? #11

Open
ghost opened this issue Jan 17, 2023 · 1 comment

Comments

@ghost
Copy link

ghost commented Jan 17, 2023

Can you, give a way to ask to an IoT Hub, located behind a firewall that only accept HTTPS/WebSockets (port 443) traffic and blocks AMQP (port 5671) and APQPS (port 5672), to send a Cloud To Device message?

The bellow schema shows where the issue is located (in surrounded HTTPS (443) between My Python Software using Azure IoT Hub Service API SDK and AZURE IoT Hub:

┌─────────────────────────────────────────────────┐
│ ┌─────────────────────┐                       ┌─┴─┐      ┌──────────────────┐
│ │ My Python Software  ├─<─── AMQPS (5671) ──>X│ F │      │  AZURE IoT Hub   │
│ │ using Azure Iot Hub ├─<─── AMQP  (5672) ──>X│ i │      │                  │
│ │ Service API SDK     │   ╔═══════════════╗   │ r │      │                  │
│ │                     ├─<─╫─ HTTPS (443) ─╫─>─│ e ├─<──>─┤                  │
│ └─────────────────────┘   ╚═══════════════╝   │ w │      └────────────────┬─┘
│                                               │ a │                       ^
│                                               │ l │                       │
│                                               │ l │                       v
│  Corporate Network                            └─┬─┘     ┌─────────────────┴─┐
└─────────────────────────────────────────────────┘    ┌──┤      Firewall     ├────┐
                                                       │  └─────────────────┬─┘    │
                                                       │    X       X       │      │
                                                       │    ^       ^       ^      │
                                                       │   MQTT   MQTTS    HTTPS   │
                                                       │  (1883)  (8883)   (443)   │
                                                       │    v       v       v      │
                                                       │ ┌──┴───────┴───────┴──┐   │
                                                       │ │ My Iot Device       ├┐  │
                                                       │ │ using Azure IoT Hub │├┐ │
                                                       │ │ Device API SDK      │││ │
                                                       │ └┬────────────────────┘││ │
                                                       │  └┬────────────────────┘│ │
                                                       │   └─────────────────────┘ │
                                                       │                           │
                                                       │ Customer Network          │
                                                       └───────────────────────────┘

The azure.iot.hub.IoTHubRegistryManager does have any constructor parameter to specify that we want to use AMQP Over WebSocket (GitHub link) when calling send_c2d_message (GitHub link).

Direct use of uamqp with uamqp.SendClient passing transport_type=uamqp.constants.TransportType.AmqpOverWebsocket in the constructor does not work either. Even if we specify that we want to use AMQP Over WebSocket (port 443), it uses AMQPS (port 5671) and it is certainly due to the format of the target passed to the constructor that should not start by "amqps://" like in the test_azure_event_hubs_send.py example (GitHub link).
Can you please, give me what should be the target pattern when specifying AmqpOverWebsocket ?

On the other hand, the Azure IoT Hub Service API Java SDK works when using com.microsoft.azure.sdk.iot.service.messaging.IotHubServiceClientProtocol.AMQPS_WS as com.microsoft.azure.sdk.iot.service.messaging.MessagingClient constructor parameter (GitHub link).

Thanks for your help

@AndreRicardo-Zoetis
Copy link

AndreRicardo-Zoetis commented Dec 12, 2024

Also interested in this as AMQPS 5671 port currently is blocked.

Seems AMQPS is the only available protocol?

self.amqp_client = uamqp.SendClient(
target="amqps://" + hostname + "/messages/devicebound",
auth=auth,
keep_alive_interval=120,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant