Azure / azure-uamqp-c

AMQP library for C
Other
59 stars 62 forks source link

Connect to service bus via WebSockets #353

Open MikDal002 opened 3 years ago

MikDal002 commented 3 years ago

Hello, I am looking for a way to connect to the service bus via web sockets. I wasn't able to make qpid-proton-c working for me. I found that azure-iot-c works over WS with IoT Hub, which brought me here. Unfortunately, I can't found connection parameters that I should provide to the "websocket_example" example. Of course, I filled IOT_HUB_HOST with "dev-myservicebusname.servicebus.windows.net", into IOT_HUB_DEVICE_NAME i wrote SharedAccessKeyName from Service Bus, into IOT_HUB_DEVICE_KEY.

I replaced authorization method to avoid using certificates:

//(void)xio_setoption(ws_io, "TrustedCerts", iothub_certs); <- that was originally in the example
SASL_PLAIN_CONFIG sasl_plain_config = { IOT_HUB_DEVICE_NAME, IOT_HUB_DEVICE_KEY, NULL };
SASL_MECHANISM_HANDLE sasl_mechanism_handle = saslmechanism_create(saslmssbcbs_get_interface(),  &sasl_plain_confi

At this moment I completely don't know what I should write in place of

Errors I receive:

Error: Time:Wed Oct 21 13:45:04 2020 File:/mnt/c/Users/mikdal/source/repos/azure-iot-sdk-c/c-utility/src/uws_client.c Func:on_underlying_io_bytes_received Line:1183 Bad status (400) received in WebSocket Upgrade response
Error: Time:Wed Oct 21 13:45:04 2020 File:/mnt/c/Users/mikdal/source/repos/azure-iot-sdk-c/c-utility/src/wsio.c Func:internal_close Line:149 wsio_close when not open.
Error: Time:Wed Oct 21 13:45:04 2020 File:/mnt/c/Users/mikdal/source/repos/azure-iot-sdk-c/uamqp/src/amqp_management.c Func:amqp_management_close Line:1020 AMQP management instance not open
CBS instance open failed.
Error: Time:Wed Oct 21 13:45:04 2020 File:/mnt/c/Users/mikdal/source/repos/azure-iot-sdk-c/c-utility/adapters/tlsio_openssl.c Func:decode_ssl_received_bytes Line:798 SSL channel closed in decode_ssl_received_bytes.
Error: Time:Wed Oct 21 13:45:04 2020 File:/mnt/c/Users/mikdal/source/repos/azure-iot-sdk-c/c-utility/adapters/tlsio_openssl.c Func:on_underlying_io_bytes_received Line:847 Error in decode_ssl_received_bytes.

I tried many different combinations of: IOT_HUB_HOST and queue name but with no luck. Additionally, I completely don't know where I could find any clue about useful endpoints.

MikDal002 commented 3 years ago

I made a step ahead. After looking at Event Hub example and with some deduction i finished with:

With this, I successfully putted a message to the service bus. But I came across on another barrier – I can't receive any message because of the error uamqp/src/link.c Func:link_frame_received Line:333 Cannot get initial delivery count.