Revert "fix: add WebSocket keepalive pings to prevent idle disconnects (#646) (#925)"

This reverts commit 96e5b4b639.
This commit is contained in:
Flowseal
2026-06-23 14:45:44 +03:00
parent 5cbac657dc
commit dddced6eee
4 changed files with 1 additions and 37 deletions
+1 -24
View File
@@ -266,26 +266,6 @@ async def _tcp_fallback(reader, writer, dst, port, relay_init, label, ctx: Crypt
return True
async def _ws_keepalive(ws, interval: float):
"""Send periodic WS PING frames to keep the upstream flow warm.
A non-positive interval disables keepalive. The loop exits on send
failure so a dead upstream is detected promptly instead of lingering
until the next client packet (see issue #646).
"""
if interval <= 0:
return
interval = max(1.0, interval) # reasonable minimum
try:
while True:
await asyncio.sleep(interval)
await ws.send_ping()
except (asyncio.CancelledError, ConnectionError, OSError):
return
async def bridge_ws_reencrypt(reader, writer, ws: RawWebSocket, label,
ctx: CryptoCtx,
dc=None, is_media=False,
@@ -357,15 +337,12 @@ async def bridge_ws_reencrypt(reader, writer, ws: RawWebSocket, label,
tasks = [asyncio.create_task(tcp_to_ws()),
asyncio.create_task(ws_to_tcp())]
keepalive = asyncio.create_task(
_ws_keepalive(ws, proxy_config.ws_keepalive_interval))
try:
await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)
finally:
keepalive.cancel()
for t in tasks:
t.cancel()
for t in (*tasks, keepalive):
for t in tasks:
try:
await t
except BaseException: