Merge pull request #7756 from wizrds/feat/secure-ws-conn

Support SSL in WebSocket connection
This commit is contained in:
Matthias
2022-11-22 19:18:16 +01:00
committed by GitHub
5 changed files with 48 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ class Producer(TypedDict):
name: str
host: str
port: int
secure: bool
ws_token: str
@@ -180,7 +181,8 @@ class ExternalMessageConsumer:
host, port = producer['host'], producer['port']
token = producer['ws_token']
name = producer['name']
ws_url = f"ws://{host}:{port}/api/v1/message/ws?token={token}"
scheme = 'wss' if producer.get('secure', False) else 'ws'
ws_url = f"{scheme}://{host}:{port}/api/v1/message/ws?token={token}"
# This will raise InvalidURI if the url is bad
async with websockets.connect(