Configure a retry mechanism
更新时间:
复制 MD 格式
Alibaba Cloud SDK V2.0 for Node.js automatically retries requests that fail due to network errors. Business logic errors, such as invalid parameters or missing resources, are not retried. If a request fails due to a business logic error, adjust the request based on the corresponding error message instead of retrying.
Configuration
Note
RuntimeOptions override the default retry settings.
-
We recommend using the default retry settings. By default, retries are disabled. If you enable automatic retries without specifying maxAttempts, the SDK retries up to three times.
-
Configure retries with RuntimeOptions:
const { RuntimeOptions } = require('@alicloud/tea-util'); // Create a RuntimeOptions instance and set the runtime parameters. const runtime = new RuntimeOptions({ // Enable automatic retries. autoretry: true, // Set the number of retries. maxAttempts: 3, });import * as $Util from '@alicloud/tea-util'; // Create a RuntimeOptions instance and set the runtime parameters. const runtime = new $Util.RuntimeOptions({ // Enable automatic retries. autoretry: true, // Set the number of retries. maxAttempts: 3, });
该文章对您有帮助吗?