wss:// is non-negotiable
Production WebSocket runs over TLS. Many corporate firewalls and proxies block ws:// outright. Cleartext exposes auth tokens to anyone on the path. The setup is identical to HTTPS — TLS terminates at the proxy or the application, the WebSocket runs over the same TLS stream. Get a free certificate via Let's Encrypt; renew automatically.
Security checklist
Treat the handshake as the auth boundary. Validate origin (browsers do not enforce CORS for WebSocket). Authenticate the user (JWT, cookies, signed token). Rate-limit per-IP and per-user. Validate every incoming message (Pydantic). Cap message size (default Starlette limit is 16MB; lower it). Cap connection counts per user (multi-device fine, multi-thousand-device suspicious).