Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.63k stars 2.84k forks source link

[AMQP Python] connection websocket/http proxy #21135

Closed yunhaoling closed 2 years ago

yunhaoling commented 3 years ago

Python doesn't provide built-in websocket support. However, there're 3rd party Python libraries supporting websocket. We need to investigate more into how to support websocket.

Background:

The AMQP WebSocket spec: http://docs.oasis-open.org/amqp-bindmap/amqp-wsb/v1.0/amqp-wsb-v1.0.html

  1. Websocket: AMQP is an application layer networking protocol. It could be built on top of tcp protocol as well as websocket protocol. The latter one is called AmqpOverWebsocket.
    AMQP          or               AMQP
    |                             |
    TCP                        Websocket
  2. Http proxy: proxy provides a way for client to connect to service in limited networking environment (e.g. for security concern, outbound port gets blocked).
    • it is feature built on top of websocket, there will a tunnel established between client and the service via the proxy using the websocket protocol.

Scope

feature requirements:

related keyword argument on client constructors:

    :keyword transport_type: The type of transport protocol that will be used for communicating with
     the Event Hubs service. Default is `TransportType.Amqp` in which case port 5671 is used.
     If the port 5671 is unavailable/blocked in the network environment, `TransportType.AmqpOverWebsocket` could
     be used instead which uses port 443 for communication.
    :paramtype transport_type: ~azure.eventhub.TransportType
    :keyword Dict http_proxy: HTTP proxy settings. This must be a dictionary with the following
     keys: `'proxy_hostname'` (str value) and `'proxy_port'` (int value).
     Additionally the following keys may also be present: `'username', 'password'`.

impacted module:

transport - consider adding a WebSocketTransport implementing the _AbstractTransport public interface:

Related materials:

uAMQP implementation:

python websocket library:

things to consider:

notes:

rakshith91 commented 2 years ago

Findings are here https://gist.github.com/rakshith91/70a4e22a5866b4efac8b91b504d736df

rakshith91 commented 2 years ago

MErged