{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/vi/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Hoạt động bất đồng bộ"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"hoạt-động-bất-đồng-bộ","__idx":0},"children":["Hoạt động bất đồng bộ"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Một số thao tác MoreLogin nhận việc trước khi trình duyệt, cloud phone, tệp, ứng dụng hoặc lần chạy RPA bên dưới đạt trạng thái cuối. Phản hồi gửi thành công nghĩa là request đã được tiếp nhận; không phải luôn nghĩa là trạng thái yêu cầu đã đạt được."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"mô-hình-trạng-thái-phía-client","__idx":1},"children":["Mô hình trạng thái phía client"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Trạng thái"},"children":["Trạng thái"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Ý nghĩa"},"children":["Ý nghĩa"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Việc client nên làm"},"children":["Việc client nên làm"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Đã gửi"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["API đã nhận lệnh hoặc đã tạo tác vụ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Lưu các ID trả về và ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requestId"]},"; đừng gửi lại ngay cùng một thao tác ghi"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Đang chờ hoặc đang chạy"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thao tác phía sau vẫn đang tiến hành"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Polling endpoint trạng thái/kết quả đã tài liệu hóa với khoảng thời gian tăng dần"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thành công"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tài nguyên hoặc tác vụ đích đã đạt trạng thái cuối thành công"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Ngừng polling và tiếp tục luồng công việc"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thất bại"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Endpoint trạng thái/kết quả báo thất bại hoặc lỗi nghiệp vụ ở trạng thái cuối"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Ngừng thử lại tự động; giữ lại ID, chi tiết lỗi và ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requestId"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Kết quả chưa xác định"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thao tác ghi bị timeout hoặc kết nối đóng mà không có phản hồi dùng được"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Hãy truy vấn trạng thái hiện tại của tài nguyên/tác vụ trước khi quyết định thử lại"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"quy-tắc-polling","__idx":2},"children":["Quy tắc polling"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Bắt đầu khoảng 1 giây, rồi tăng khoảng cách lên 2, 4, 8 giây, giới hạn ở 15–30 giây."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Thêm jitter để nhiều client không polling cùng một thời điểm."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Dừng khi đạt trạng thái cuối đã tài liệu hóa; đừng polling vô hạn."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Chỉ coi ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data: null"]}," là đang chờ khi endpoint ghi rõ hành vi đó."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Timeout truyền tải ở một thao tác ghi không phải bằng chứng thất bại."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"các-luồng-đã-tài-liệu-hóa","__idx":3},"children":["Các luồng đã tài liệu hóa"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Luồng"},"children":["Luồng"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Thao tác gửi"},"children":["Thao tác gửi"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Thao tác quan sát"},"children":["Thao tác quan sát"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Trạng thái cuối"},"children":["Trạng thái cuối"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Mở/đóng cloud browser"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudbrowser/start"]}," hoặc ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/cloudbrowser/stop"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudbrowser/page"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Runtime đạt trạng thái mong muốn hoặc biến mất sau khi đóng"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Bật/tắt Cloud Phone"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/powerOn"]}," hoặc ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/cloudphone/powerOff"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/page"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["envStatus=4"]}," đã bật hoặc ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["envStatus=2"]}," đã tắt; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["1"]}," là lỗi tạo"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tải tệp lên Cloud Phone"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tải lên URL đã ký, rồi ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/uploadFile"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/uploadFileResult"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status=1"]}," thành công hoặc ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status=2"]}," thất bại; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data: null"]}," và ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status=0"]}," là đang chờ"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tải xuống từ Cloud Phone"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/download"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/download/result"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["status=20"]}," thành công, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["30"]}," thất bại, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["40"]}," đã hủy; ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["10"]}," là đang chạy"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Cài đặt ứng dụng"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/app/install"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/app/installedList"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Gói được yêu cầu xuất hiện trong danh sách ứng dụng đã cài"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Lên lịch/chạy RPA"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/rpa/task/save"]}," hoặc ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/onceTask/save"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/rpa/task/page"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/subTask/page"]}," và ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/subTask/detail/{id}"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["taskState=2"]}," đã xong hoặc ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["3"]}," đã hủy; xem ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["handleResult"]}," (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0"]}," thất bại, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["1"]}," thành công)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Phát trực tiếp"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/live/start"]}," hoặc ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/live/end"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudphone/live/status"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Trạng thái xác nhận đã bắt đầu hoặc đã dừng phát"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tải lên cloud storage"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudstorage/upload/init"]},", sau đó ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PUT"]}," lên object store"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /cloudstorage/upload/complete"]}," sau khi mọi PUT cần thiết thành công"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Request hoàn tất thành công; đừng bao giờ gọi complete trước khi tải đối tượng lên thành công"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Các thao tác tương ứng của Local API dùng tiền tố ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api"]}," ở những nơi đã tài liệu hóa. Xem ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/vi/api-reference/getting-started/endpoint-behavior"},"children":["Ma trận thử lại và hoàn tất endpoint"]}," để có hướng dẫn theo từng thao tác."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"ví-dụ-khôi-phục-sau-timeout","__idx":4},"children":["Ví dụ khôi phục sau timeout"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"try:\n    submit_operation()\nexcept TimeoutError:\n    # The write may already have succeeded.\n    current = query_current_state()\n    if current.is_terminal_success:\n        pass\n    elif current.is_pending:\n        poll_until_terminal()\n    else:\n        decide_whether_retry_is_safe(current)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["API công khai hiện chưa định nghĩa header khóa idempotency dùng chung. Vì vậy ID tài nguyên, ID tác vụ, truy vấn trạng thái và ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requestId"]}," là thiết yếu để khôi phục an toàn."]}]},"headings":[{"value":"Hoạt động bất đồng bộ","id":"hoạt-động-bất-đồng-bộ","depth":1},{"value":"Mô hình trạng thái phía client","id":"mô-hình-trạng-thái-phía-client","depth":2},{"value":"Quy tắc polling","id":"quy-tắc-polling","depth":2},{"value":"Các luồng đã tài liệu hóa","id":"các-luồng-đã-tài-liệu-hóa","depth":2},{"value":"Ví dụ khôi phục sau timeout","id":"ví-dụ-khôi-phục-sau-timeout","depth":2}],"frontmatter":{"seo":{"title":"Hoạt động bất đồng bộ"}},"lastModified":"2026-09-03T05:46:01.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/vi/api-reference/getting-started/async-operations","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}