From 838b4f4e52b388e905d6cbbd32e0c7421b7d1ec1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 05:29:17 +0000 Subject: [PATCH 1/3] chore(deps): bump websockets from 13.1 to 14.0 Bumps [websockets](https://github.com/python-websockets/websockets) from 13.1 to 14.0. - [Release notes](https://github.com/python-websockets/websockets/releases) - [Commits](https://github.com/python-websockets/websockets/compare/13.1...14.0) --- updated-dependencies: - dependency-name: websockets dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8841ce9c8..a78ca1e6c 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 From c9fb3dfb1d8a0f591926236726d15717b5816035 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 11 Nov 2024 07:09:13 +0100 Subject: [PATCH 2/3] chore: Update websocket imports to use "legacy" client temporary - must be updated to the new implementation --- freqtrade/rpc/api_server/ws/proxy.py | 2 +- freqtrade/rpc/api_server/ws/types.py | 2 +- freqtrade/rpc/external_message_consumer.py | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/freqtrade/rpc/api_server/ws/proxy.py b/freqtrade/rpc/api_server/ws/proxy.py index 7b19834bc..24eb20585 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.legacy.client import WebSocketClientProtocol 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..0660bbd69 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.legacy.client import WebSocketClientProtocol 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..ed6945458 100644 --- a/freqtrade/rpc/external_message_consumer.py +++ b/freqtrade/rpc/external_message_consumer.py @@ -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) From 60ec9739c2290c0760582375c2572ff977ddc94f Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 11 Nov 2024 19:21:43 +0100 Subject: [PATCH 3/3] chore: update websocket implementation to new asyncio api --- freqtrade/rpc/api_server/ws/proxy.py | 2 +- freqtrade/rpc/api_server/ws/types.py | 2 +- freqtrade/rpc/external_message_consumer.py | 2 +- scripts/ws_client.py | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/freqtrade/rpc/api_server/ws/proxy.py b/freqtrade/rpc/api_server/ws/proxy.py index 24eb20585..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.legacy.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 0660bbd69..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.legacy.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 ed6945458..fe22613bd 100644 --- a/freqtrade/rpc/external_message_consumer.py +++ b/freqtrade/rpc/external_message_consumer.py @@ -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.legacy.client.connect( + async with websockets.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: 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)