chore: Update websocket imports to use "legacy" client

temporary - must be updated to the new implementation
This commit is contained in:
Matthias
2024-11-11 07:09:13 +01:00
parent 838b4f4e52
commit c9fb3dfb1d
3 changed files with 4 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
from typing import Any
from fastapi import WebSocket as FastAPIWebSocket
from websockets.client import WebSocketClientProtocol as WebSocket
from websockets.legacy.client import WebSocketClientProtocol as WebSocket
from freqtrade.rpc.api_server.ws.types import WebSocketType

View File

@@ -1,7 +1,7 @@
from typing import Any, TypeVar
from fastapi import WebSocket as FastAPIWebSocket
from websockets.client import WebSocketClientProtocol as WebSocket
from websockets.legacy.client import WebSocketClientProtocol as WebSocket
WebSocketType = TypeVar("WebSocketType", FastAPIWebSocket, WebSocket)

View File

@@ -193,7 +193,7 @@ class ExternalMessageConsumer:
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(
async with websockets.legacy.client.connect(
ws_url, max_size=self.message_size_limit, ping_interval=None
) as ws:
async with create_channel(ws, channel_id=name, send_throttle=0.5) as channel:
@@ -213,8 +213,7 @@ class ExternalMessageConsumer:
except (
socket.gaierror,
ConnectionRefusedError,
websockets.exceptions.InvalidStatusCode,
websockets.exceptions.InvalidMessage,
websockets.exceptions.InvalidHandshake,
) as e:
logger.error(f"Connection Refused - {e} retrying in {self.sleep_time}s")
await asyncio.sleep(self.sleep_time)