diff --git a/freqtrade/rpc/api_server/ws/proxy.py b/freqtrade/rpc/api_server/ws/proxy.py index 7b19834bc..c32494176 100644 --- a/freqtrade/rpc/api_server/ws/proxy.py +++ b/freqtrade/rpc/api_server/ws/proxy.py @@ -1,7 +1,7 @@ from typing import Any from fastapi import WebSocket as FastAPIWebSocket -from websockets.client import WebSocketClientProtocol as WebSocket +from websockets.asyncio.client import ClientConnection as WebSocket from freqtrade.rpc.api_server.ws.types import WebSocketType diff --git a/freqtrade/rpc/api_server/ws/types.py b/freqtrade/rpc/api_server/ws/types.py index 8f7dad33b..7ce2eb4bf 100644 --- a/freqtrade/rpc/api_server/ws/types.py +++ b/freqtrade/rpc/api_server/ws/types.py @@ -1,7 +1,7 @@ from typing import Any, TypeVar from fastapi import WebSocket as FastAPIWebSocket -from websockets.client import WebSocketClientProtocol as WebSocket +from websockets.asyncio.client import ClientConnection as WebSocket WebSocketType = TypeVar("WebSocketType", FastAPIWebSocket, WebSocket) diff --git a/freqtrade/rpc/external_message_consumer.py b/freqtrade/rpc/external_message_consumer.py index eb69c4876..fe22613bd 100644 --- a/freqtrade/rpc/external_message_consumer.py +++ b/freqtrade/rpc/external_message_consumer.py @@ -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) diff --git a/requirements.txt b/requirements.txt index bed1ca60a..c27ab0201 100644 --- a/requirements.txt +++ b/requirements.txt @@ -57,7 +57,7 @@ pytz==2024.2 schedule==1.2.2 #WS Messages -websockets==13.1 +websockets==14.0 janus==1.1.0 ast-comments==1.2.2 diff --git a/scripts/ws_client.py b/scripts/ws_client.py index 81e539e26..46dd2da10 100755 --- a/scripts/ws_client.py +++ b/scripts/ws_client.py @@ -253,8 +253,7 @@ async def create_client( except ( socket.gaierror, ConnectionRefusedError, - websockets.exceptions.InvalidStatusCode, - websockets.exceptions.InvalidMessage, + websockets.exceptions.InvalidHandshake, ) as e: logger.error(f"Connection Refused - {e} retrying in {sleep_time}s") await asyncio.sleep(sleep_time)