All Products
Search
Document Center

Alibaba Cloud SDK:retry mechanism

Last Updated:Oct 14, 2025

The V2.0 software development kit (SDK) has a built-in automatic retry mechanism for network exceptions in OpenAPI requests. If a request fails because of a network problem, the system automatically retries the request to improve service stability and reliability. 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 resending the request. This topic describes how to configure the automatic retry mechanism for network exceptions in the V2.0 SDK.

Configuration methods for the retry mechanism

Note

Configurations in RuntimeOptions take precedence over the default configurations.

  • Use the default configurations. By default, the retry feature is disabled. If you enable retries without setting the number of retries, the system retries the request a maximum of three times.

  • Use the com.aliyun.teautil.models.RuntimeOptions class to configure the retry mechanism for a specific request.

    com.aliyun.teautil.models.RuntimeOptions runtimeOptions = new com.aliyun.teautil.models.RuntimeOptions();
    // Enable the automatic retry mechanism.
    runtimeOptions.autoretry = true;
    // Set the maximum number of automatic retries.
    runtimeOptions.maxAttempts = 3;