Spaces:
Running
Running
Commit ·
7effe71
1
Parent(s): 6e8a8ab
Add WebSocket diagnostic script for debugging audio issues
Browse files- app.py +4 -4
- debug_websocket.py +48 -0
app.py
CHANGED
|
@@ -119,14 +119,14 @@ def start_services():
|
|
| 119 |
# Test détaillé des services
|
| 120 |
logger.info("🔍 Test détaillé des services...")
|
| 121 |
try:
|
| 122 |
-
result = subprocess.run([sys.executable, "
|
| 123 |
capture_output=True, text=True, timeout=30)
|
| 124 |
if result.stdout:
|
| 125 |
-
logger.info(f"Résultats des tests:\n{result.stdout}")
|
| 126 |
if result.stderr:
|
| 127 |
-
logger.error(f"Erreurs des tests:\n{result.stderr}")
|
| 128 |
except Exception as e:
|
| 129 |
-
logger.warning(f"Impossible d'exécuter les tests
|
| 130 |
|
| 131 |
logger.info("✅ Services backend démarrés et testés")
|
| 132 |
return True
|
|
|
|
| 119 |
# Test détaillé des services
|
| 120 |
logger.info("🔍 Test détaillé des services...")
|
| 121 |
try:
|
| 122 |
+
result = subprocess.run([sys.executable, "debug_websocket.py"],
|
| 123 |
capture_output=True, text=True, timeout=30)
|
| 124 |
if result.stdout:
|
| 125 |
+
logger.info(f"Résultats des tests WebSocket:\n{result.stdout}")
|
| 126 |
if result.stderr:
|
| 127 |
+
logger.error(f"Erreurs des tests WebSocket:\n{result.stderr}")
|
| 128 |
except Exception as e:
|
| 129 |
+
logger.warning(f"Impossible d'exécuter les tests WebSocket: {e}")
|
| 130 |
|
| 131 |
logger.info("✅ Services backend démarrés et testés")
|
| 132 |
return True
|
debug_websocket.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Script de diagnostic pour le problème WebSocket
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import asyncio
|
| 7 |
+
import aiohttp
|
| 8 |
+
import json
|
| 9 |
+
import sys
|
| 10 |
+
|
| 11 |
+
async def test_websocket_connection():
|
| 12 |
+
"""Teste la connexion WebSocket"""
|
| 13 |
+
print("🔍 Test de connexion WebSocket...")
|
| 14 |
+
|
| 15 |
+
try:
|
| 16 |
+
# Test de connexion WebSocket
|
| 17 |
+
async with aiohttp.ClientSession() as session:
|
| 18 |
+
async with session.ws_connect("ws://localhost:5003/live_stream/test_user?lang=fr&room_id=test") as ws:
|
| 19 |
+
print("✅ Connexion WebSocket établie")
|
| 20 |
+
|
| 21 |
+
# Envoyer un message de test
|
| 22 |
+
test_message = {"type": "start", "user_id": "test_user"}
|
| 23 |
+
await ws.send_str(json.dumps(test_message))
|
| 24 |
+
print("✅ Message de test envoyé")
|
| 25 |
+
|
| 26 |
+
# Attendre une réponse
|
| 27 |
+
try:
|
| 28 |
+
async with asyncio.timeout(5):
|
| 29 |
+
msg = await ws.receive()
|
| 30 |
+
print(f"✅ Réponse reçue: {msg}")
|
| 31 |
+
except asyncio.TimeoutError:
|
| 32 |
+
print("⚠️ Aucune réponse reçue dans les 5 secondes")
|
| 33 |
+
|
| 34 |
+
await ws.close()
|
| 35 |
+
print("✅ Connexion WebSocket fermée")
|
| 36 |
+
|
| 37 |
+
except Exception as e:
|
| 38 |
+
print(f"❌ Erreur WebSocket: {e}")
|
| 39 |
+
import traceback
|
| 40 |
+
print(f"Traceback: {traceback.format_exc()}")
|
| 41 |
+
|
| 42 |
+
async def main():
|
| 43 |
+
print("🚀 Démarrage du diagnostic WebSocket...")
|
| 44 |
+
await test_websocket_connection()
|
| 45 |
+
print("✅ Diagnostic terminé")
|
| 46 |
+
|
| 47 |
+
if __name__ == "__main__":
|
| 48 |
+
asyncio.run(main())
|