All Products
Search
Document Center

Alibaba Cloud SDK:Retry mechanism

Last Updated:Oct 14, 2025

The V2.0 software development kit (SDK) includes a built-in automatic retry mechanism for network exceptions that occur during OpenAPI request processing. If a request fails because of a network issue, the system automatically retries the request to improve service stability and reliability. However, the SDK does not retry requests that fail because of business logic errors, such as invalid parameters or a resource that does not exist. Your application must handle these errors based on the specific error message instead of retrying the request. This topic describes how to configure the automatic retry mechanism for network exceptions in the V2.0 SDK.

Configuration methods

Note

Configuration priority: RuntimeOptions settings take precedence over the default configurations.

  • Use the default configurations. By default, requests are not retried. If you enable retries but do not specify the number of retries, the system retries the request up to three times.

  • Configure the retry mechanism using runtime parameters (RuntimeOptions).

    from alibabacloud_tea_util.models import RuntimeOptions
    
    runtimeOptions = RuntimeOptions(
        autoretry=True,  # Specifies whether to enable retries. Retries are disabled by default.
        max_attempts=3  # The number of maximum retry attempts. The default value is 3.
    )