Set websocket open timeout to 1 minute and log attempts
This commit is contained in:
parent
2ddb2639bf
commit
4410009015
|
@ -28,10 +28,16 @@ async def websocket_source(
|
||||||
from websockets.client import connect
|
from websockets.client import connect
|
||||||
from websockets.exceptions import WebSocketException
|
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:
|
while True:
|
||||||
try:
|
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:
|
while (msg := await ws.recv()) is not None:
|
||||||
event = loads(msg)
|
event = loads(msg)
|
||||||
logger.debug("data: %r", event)
|
logger.debug("data: %r", event)
|
||||||
|
|
Loading…
Reference in New Issue