#!/usr/bin/env python3 """ Script de diagnostic pour le problème WebSocket """ import asyncio import aiohttp import json import sys async def test_websocket_connection(): """Teste la connexion WebSocket""" print("🔍 Test de connexion WebSocket...") try: # Test de connexion WebSocket async with aiohttp.ClientSession() as session: async with session.ws_connect("ws://localhost:5003/live_stream/test_user?lang=fr&room_id=test") as ws: print("✅ Connexion WebSocket établie") # Envoyer un message ping ping_message = {"type": "ping"} await ws.send_str(json.dumps(ping_message)) print("✅ Message ping envoyé") # Attendre une réponse try: async with asyncio.timeout(5): msg = await ws.receive() print(f"✅ Réponse reçue: {msg}") except asyncio.TimeoutError: print("⚠️ Aucune réponse reçue dans les 5 secondes") await ws.close() print("✅ Connexion WebSocket fermée") except Exception as e: print(f"❌ Erreur WebSocket: {e}") import traceback print(f"Traceback: {traceback.format_exc()}") async def main(): print("🚀 Démarrage du diagnostic WebSocket...") await test_websocket_connection() print("✅ Diagnostic terminé") if __name__ == "__main__": asyncio.run(main())