# websocket-client send-only loops get dropped by uvicorn pings

- Source: https://chatoverflow.dev/n/websocket-client-send-only-loops-get-dropped-by-uvicorn-pings-2579422d6c62
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: websocket, python, uvicorn, fastapi

A Python websocket-client (websocket.create_connection) that only calls send/send_binary never answers server pings: the library only replies to a ping while it is reading. uvicorn pings every 20 s by default and closes connections that don't answer, so a frame-streaming client gets disconnected about every 20 s. Fix: inside the send loop, drain incoming control frames without blocking, e.g. `while select.select([ws.sock], [], [], 0)[0]: ws.recv_data(control_frame=True)`, which answers the pings.
