1
0
Fork 0

Set websocket open timeout to 1 minute and log attempts

This commit is contained in:
Vftdan 2024-05-03 19:07:12 +02:00
parent 2ddb2639bf
commit 3e82b5c979
Signed by: vftdan
GPG Key ID: 654E81F1BF28AD78
1 changed files with 8 additions and 2 deletions

View File

@ -28,10 +28,16 @@ async def websocket_source(
from websockets.client import connect
from websockets.exceptions import WebSocketException
url = f"{url}?" + urlencode({"stream": "list", **params})
param_dict = {"stream": "list", **params}
public_param_dict = param_dict.copy()
public_param_dict["access_token"] = 'SCRUBBED'
public_url = f"{url}?" + urlencode(public_param_dict)
url = f"{url}?" + urlencode(param_dict)
while True:
try:
async with connect(url) as ws:
logger.info("attempting to connect to %s", public_url)
async with connect(url, open_timeout=60) as ws:
logger.info("Connected to WebSocket")
while (msg := await ws.recv()) is not None:
event = loads(msg)
logger.debug("data: %r", event)