Retry mechanism

更新时间:
复制 MD 格式

The V2.0 SDK automatically retries OpenAPI requests that fail due to network issues to improve service stability and reliability. Requests that fail due to business logic errors, such as invalid parameters or non-existent resources, are not retried.

Configuration methods

Note

The RuntimeOptions configuration takes precedence over the default configuration.

  • Use the default configuration. By default, failed requests are not retried. If you enable retries but do not specify the maximum number of attempts, a request is retried up to three times.

  • Configure the retry mechanism for the current request using AlibabaCloud.TeaUtil.Models.RuntimeOptions.

    // Configure runtime parameters. The settings are valid only for requests that use this RuntimeOptions instance.
    var runtimeOptions = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
    // Enable the automatic retry mechanism.
    runtimeOptions.Autoretry = true;
    // Set the maximum number of retries.
    runtimeOptions.MaxAttempts = 3;