File size: 1,598 Bytes
7effe71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7bfdc04
 
 
 
7effe71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/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())