Overview
FastAPI 0.115, released on November 9, 2024, improves WebSocket support with new configuration and connection management options.
Main Features
Improved WebSocket
WebSocket endpoints benefit from better error handling and new connection configuration options.
python
from fastapi import FastAPI, WebSocket
app = FastAPI()
@app.websocket('/ws')
async def websocket_endpoint(websocket: WebSocket):
await websocket.accept()
while True:
data = await websocket.receive_text()
await websocket.send_text(f'Received: {data}')
