From 60f22e30b66b345a9eb6acd85504ea53f61f25e5 Mon Sep 17 00:00:00 2001 From: zakhy <=> Date: Tue, 22 Apr 2025 11:48:55 +0700 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8?= =?UTF-8?q?=20=D1=80=D0=B5=D1=82=D1=80=D0=B0=D0=B5=D0=B2=20=D0=B8=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=BC=D0=B8=D1=81=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/workerslocation/commands/radiusip.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/workerslocation/commands/radiusip.py b/apps/workerslocation/commands/radiusip.py index 3cf78f7..42c2bce 100644 --- a/apps/workerslocation/commands/radiusip.py +++ b/apps/workerslocation/commands/radiusip.py @@ -77,8 +77,8 @@ async def send_messages(websocket, message): async def handle_channel_transmission(channel, voice_call, websocket, auth_dict, promise_id_start): ssrc = SSRC source_id = auth_dict["client_id"] - promise_id = promise_id_start retry_attempts = 0 + promise_id = promise_id_start while retry_attempts < MAX_RETRY_ATTEMPTS: log(f"[{channel}] Попытка #{retry_attempts + 1} для отправки") @@ -86,10 +86,11 @@ async def handle_channel_transmission(channel, voice_call, websocket, auth_dict, promise_granted = False own_tx_received = False + retry_due_to_timeout = False try: while True: - raw = await asyncio.wait_for(websocket.recv(), timeout=5) + raw = await asyncio.wait_for(websocket.recv(), timeout=10) message_items = json.loads(raw) for item in message_items: @@ -97,14 +98,18 @@ async def handle_channel_transmission(channel, voice_call, websocket, auth_dict, payload = item.get("payload") if identifier != "location:0/position_broadcast": log(f"<<< Ответ получен: {item}") + if identifier == "core/promise_response" and payload.get("promise_id") == promise_id: state = payload.get("state") if state == "granted": promise_granted = True log(f"[{channel}] Promise granted.") + elif state == "queued": + log(f"[{channel}] Promise queued...") elif state == "faulted": log(f"[{channel}] Promise faulted. Ретрай...") break + elif identifier == "call:1/participant_state_broadcast": if payload.get("state") == "own_tx" and "65280" in payload.get("source", ""): own_tx_received = True @@ -122,10 +127,12 @@ async def handle_channel_transmission(channel, voice_call, websocket, auth_dict, except asyncio.TimeoutError: log(f"[{channel}] Timeout ожидания. Ретрай...") + retry_due_to_timeout = True retry_attempts += 1 promise_id += 1 - await asyncio.sleep(RETRY_DELAY_SECONDS) + if retry_attempts < MAX_RETRY_ATTEMPTS: + await asyncio.sleep(RETRY_DELAY_SECONDS) log(f"[{channel}] Не удалось отправить после {MAX_RETRY_ATTEMPTS} попыток.") return False