Python-SocketIO client frequent websocket disconnect from the server #5428
Unanswered
prawebdesign
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm experiencing persistent WebSocket disconnections (every 30 second to few minutes) in production on Azure App Service during long-running operations (60-120 seconds), despite extensive timeout configurations. (Switching to HTTP long-polling seems to have fixed disconnection issues) I need community validation: Is WebSocket fundamentally unsuitable for my architecture, or am I missing something?
Architecture Overview
Technology Versions
python-socketio==5.15.1+python-engineio==4.12.3uvicorn.workers.UvicornWorkerpython-socketioclient with Azure AD authenticationsocket.io-clientbrowser libraryUse Case
Test automation system where:
Symptoms
Server-Side Logs (WebSocket Mode)
[PYTHON CLIENT] ===== DISCONNECT EVENT =====
[PYTHON CLIENT] Disconnected from server at 1765991928.5393806
[PYTHON CLIENT] Was in room: copied_scriptc315050f-5e8a-428e-bf7e-825798c40a7f6967-725264
[PYTHON CLIENT] Connected status: True
[PYTHON CLIENT] SIO object exists: True
[PYTHON CLIENT] SIO connected: True
[PYTHON CLIENT] Call stack at disconnect:
[PYTHON CLIENT] File "\\python_environments\py312\python-3.12.2.amd64\Lib\threading.py", line 1030, in _bootstrap
self._bootstrap_inner()
[PYTHON CLIENT] File "\\python_environments\py312\python-3.12.2.amd64\Lib\threading.py", line 1073, in _bootstrap_inner
self.run()
[PYTHON CLIENT] File "\\python_environments\py312\python-3.12.2.amd64\Lib\threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
[PYTHON CLIENT] File "\\python_environments\py312\python-3.12.2.amd64\Lib\site-packages\engineio\client.py", line 560, in _read_loop_websocket
self._trigger_event('disconnect', self.reason.TRANSPORT_ERROR,
[PYTHON CLIENT] File "\\python_environments\py312\python-3.12.2.amd64\Lib\site-packages\engineio\client.py", line 465, in _trigger_event
return self.handlersevent
[PYTHON CLIENT] File "\\python_environments\py312\python-3.12.2.amd64\Lib\site-packages\socketio\client.py", line 546, in _handle_eio_disconnect
self._trigger_event('disconnect', n, reason)
[PYTHON CLIENT] File "\\python_environments\py312\python-3.12.2.amd64\Lib\site-packages\socketio\client.py", line 449, in _trigger_event
return handler(*args[:-1])
[PYTHON CLIENT] Will attempt reconnection...
[PYTHON CLIENT] ================================```
What Works vs. What Doesn't
transports=['websocket']transports=['websocket', 'polling']transports=['polling']Community Input Needed
Is this a known limitation? Are there documented issues with WebSocket through Azure Application Gateway + Nginx + Gunicorn stack?
Am I missing a configuration? Is there an Azure-specific setting or Nginx directive that makes WebSocket stable in this environment?
Is polling acceptable for production? Given 60-120 second operations with real-time progress updates, is HTTP long-polling a viable long-term solution?
Has anyone solved this differently? Alternative approaches that maintain WebSocket in similar architectures?
What's the root cause? If all timeouts are fixed, what mechanism is still causing the Engine.IO
abort=Truedisconnections?Any insights from the community would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions