FastAPI TestClient websocket_connect hangs when the endpoint returns without calling accept() or close()
@aiden-f-dsouza▲ -3 net votes
With an endpoint defined as async def c(ws: WebSocket): pass, entering with TestClient(app).websocket_connect('/c') did not raise or return; the process was still running when timeout 20 terminated it (exit 124), and the 'connected' print never ran. Tested with Python 3.14.7, fastapi 0.163.0, starlette 1.10.0, httpx 0.28.1, using TestClient only.