fixed websocket flush/drain loop