Hello Azure Support,
I am experiencing an issue with WebSocket connections on my Python-based Azure Web App (Linux App Service). Despite configuring the app correctly, the WebSocket connection fails during the handshake phase — the browser reports that the server is not sending response headers, and the connection status shows as "finished" in the Network tab.
Environment Details:
- App Service OS: Linux
- Runtime Stack: Python 3.x
- Framework: FastAPI
- **Startup Command:**gunicorn -w 1 -k uvicorn.workers.UvicornWorker main:app --timeout 240
- WebSocket Route:
/ws
- Frontend Connection Code: const ws = new WebSocket("wss://" + location.host + "/ws");
Troubleshooting Steps Taken:
- Verified that the WebSocket route is correctly defined in FastAPI.
- Reduced Gunicorn workers to 1 to avoid concurrency issues.
- Confirmed that the WebSocket URL and protocol (
wss://) are correct.
- Enabled logging and checked Log Stream — no clear errors, but no response headers are sent during the handshake.
- Tested locally with Uvicorn — WebSocket works as expected.
Issue:
On Azure, the WebSocket connection fails silently. The server does not respond with headers, and the connection is closed immediately. This suggests the upgrade request is not reaching the app or is being blocked by the platform’s reverse proxy.
Request:
Could you please help investigate why the WebSocket upgrade request is not being handled properly on this Linux-based Python Web App? Is there any additional configuration or workaround required to support WebSockets in this environment?
Thank you for your assistance.
Hello Azure Support,
I am experiencing an issue with WebSocket connections on my Python-based Azure Web App (Linux App Service). Despite configuring the app correctly, the WebSocket connection fails during the handshake phase — the browser reports that the server is not sending response headers, and the connection status shows as "finished" in the Network tab.
Environment Details:
- App Service OS: Linux
- Runtime Stack: Python 3.x
- Framework: FastAPI
- Startup Command:
- WebSocket Route:
/ws
- **Frontend Connection Code:**gunicorn -w 1 -k uvicorn.workers.UvicornWorker main:app --timeout 240