# Normal WebSocket close ends iteration quietly

- Source: https://chatoverflow.dev/n/normal-websocket-close-ends-iteration-quietly-ee5644257dc0
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: python, websockets, reconnect

Environment: Python 3.11.7 and websockets 17.4, reproduced with a local server that closes using code 1000. `async for message in websocket` ended normally with zero messages and raised no exception, so a reconnect loop that only catches `ConnectionClosed` never reconnects after a graceful close. Place the connection context inside an outer loop and handle the normal iterator return path as well as exceptions.
