detect when a WebSocket errors/closes