Spaces:
Runtime error
Runtime error
Commit
·
2548f77
1
Parent(s):
283bd91
Update main.py
Browse files
main.py
CHANGED
@@ -158,7 +158,7 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
158 |
while True:
|
159 |
try:
|
160 |
# Receive user input with a timeout
|
161 |
-
data = await asyncio.wait_for(websocket.receive_json(), timeout=
|
162 |
|
163 |
if data.get("type") == "heartbeat":
|
164 |
await websocket.send_json({"type": "heartbeat_response"})
|
@@ -198,15 +198,15 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
198 |
|
199 |
except asyncio.TimeoutError:
|
200 |
print("WebSocket connection timed out")
|
201 |
-
break # Exit the loop on timeout
|
202 |
|
203 |
except WebSocketDisconnect:
|
204 |
print("WebSocket disconnected")
|
205 |
-
break # Exit the loop on disconnect
|
206 |
|
207 |
except Exception as e:
|
208 |
print(f"Error in WebSocket connection {client_id}: {e}")
|
209 |
|
210 |
finally:
|
211 |
print(f"WebSocket connection closed: {client_id}")
|
212 |
-
await websocket.close() # Ensure the WebSocket is closed
|
|
|
158 |
while True:
|
159 |
try:
|
160 |
# Receive user input with a timeout
|
161 |
+
data = await asyncio.wait_for(websocket.receive_json(), timeout=90000.0)
|
162 |
|
163 |
if data.get("type") == "heartbeat":
|
164 |
await websocket.send_json({"type": "heartbeat_response"})
|
|
|
198 |
|
199 |
except asyncio.TimeoutError:
|
200 |
print("WebSocket connection timed out")
|
201 |
+
#break # Exit the loop on timeout
|
202 |
|
203 |
except WebSocketDisconnect:
|
204 |
print("WebSocket disconnected")
|
205 |
+
#break # Exit the loop on disconnect
|
206 |
|
207 |
except Exception as e:
|
208 |
print(f"Error in WebSocket connection {client_id}: {e}")
|
209 |
|
210 |
finally:
|
211 |
print(f"WebSocket connection closed: {client_id}")
|
212 |
+
#await websocket.close() # Ensure the WebSocket is closed
|