Files
lang/test_single.py
T

30 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Test: ONE big frame — does it arrive?"""
import asyncio, json, websockets, base64, os
async def test(size_kb):
uri = "wss://proxy.kube5s.ru/ws"
# old format: single message with all data
audio_b64 = base64.b64encode(os.urandom(size_kb * 1024)).decode()
msg = json.dumps({"token": "test", "audio_b64": audio_b64, "mime": "audio/webm"})
print(f"Single frame {len(msg)} chars ({size_kb}KB audio → {len(msg)/1024:.1f}KB JSON)...")
try:
async with websockets.connect(uri) as ws:
await ws.send(msg)
print(" sent, waiting...")
try:
resp = await asyncio.wait_for(ws.recv(), timeout=20)
data = json.loads(resp)
print(f" => {data.get('error','OK')} ({data.get('status','')})")
except asyncio.TimeoutError:
print(" => TIMEOUT")
except Exception as e:
print(f" => CONN_ERR: {e}")
async def main():
for kb in [10, 25, 40, 55, 70, 100]:
await test(kb)
await asyncio.sleep(1)
asyncio.run(main())