Skip to content

Commit 8dd370a

Browse files
committed
init
comment
1 parent 1f94e67 commit 8dd370a

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

packages/atproto_firehose/client.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from atproto_client.models.base import ParamsModelBase
1212
from atproto_client.models.common import XrpcError
1313
from atproto_core.exceptions import DAGCBORDecodingError
14-
from websockets.client import connect as aconnect
14+
from websockets.asyncio.client import connect as aconnect
1515
from websockets.exceptions import (
1616
ConnectionClosedError,
1717
ConnectionClosedOK,
@@ -46,8 +46,8 @@
4646

4747

4848
if t.TYPE_CHECKING:
49-
from websockets.client import ClientConnection as SyncWebSocketClient
50-
from websockets.legacy.client import Connect as AsyncConnect
49+
from websockets.asyncio.client import connect as AsyncConnect
50+
from websockets.sync.client import ClientConnection as SyncWebSocketClient
5151

5252

5353
def _build_websocket_uri(method: str, base_uri: str, params: t.Optional[t.Dict[str, t.Any]] = None) -> str:
@@ -124,9 +124,18 @@ def _websocket_uri(self) -> str:
124124
return _build_websocket_uri(self._method, self._base_uri, self._params)
125125

126126
def _get_client(self) -> 'SyncWebSocketClient':
127-
return connect(self._websocket_uri, max_size=_MAX_MESSAGE_SIZE_BYTES, close_timeout=0.1)
127+
# Disable automatic pings for sync client (added in websockets v15+)
128+
# to maintain behavior consistent with <v14 for now.
129+
return connect(
130+
self._websocket_uri,
131+
max_size=_MAX_MESSAGE_SIZE_BYTES,
132+
close_timeout=0.1,
133+
# see https://websockets.readthedocs.io/en/stable/topics/keepalive.html
134+
ping_interval=None, # Disable automatic pings
135+
)
128136

129137
def _get_async_client(self) -> 'AsyncConnect':
138+
# Async client connect function accepts ping_interval directly (default is 20s)
130139
return aconnect(self._websocket_uri, max_size=_MAX_MESSAGE_SIZE_BYTES, close_timeout=0.1)
131140

132141
def _get_reconnection_delay(self) -> int:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ python = ">=3.8,<3.14"
5353
httpx = ">=0.25.0,<0.29.0"
5454
typing-extensions = ">=4.8.0,<5"
5555
click = ">=8.1.3,<9"
56-
websockets = ">=12,<14"
56+
websockets = ">=15,<16"
5757
pydantic = ">=2.7,<3"
5858
libipld = ">=3.0.1,<4"
5959
dnspython = ">=2.4.0,<3"

0 commit comments

Comments
 (0)