When the connection drops, the pong_waiter task can be already done when ws.abort_pings() is called, leading to an InvalidStateError as abort_pings() is unconditionally calling set_exception on the pong_waiter. If that exception is not caught, we're falling outside the recovery loop and do not reconnect. To fix this, put a try block around ws.abort_pings().
When the connection drops, the pong_waiter task can be already done when ws.abort_pings() is called, leading to an InvalidStateError as abort_pings() is unconditionally calling set_exception on the pong_waiter. If that exception is not caught, we're falling outside the recovery loop and do not reconnect. To fix this, put a try block around ws.abort_pings().