close websocket before reconnecting.