Skip to main content

Timeout and Retries

These CodeGen settings allow control over retries and exponential backoff of API calls from the generated code.

Timeout

This setting defines the duration (in seconds) after which requests will time out.

Usage

To configure this feature, specify a Float value. The default value is 0, indicating no timeout.

"info": {
...,
"x-codegen-settings": {
"Timeout": 0.5
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️✔️✔️

Retry On Timeout

Enable this setting to retry request on timeout.

note

This setting needs to be enabled to use the subsequent settings on this page.

Usage

To use this feature, you need to specify a Boolean type. By default, its value is set to true.

"info": {
...,
"x-codegen-settings": {
"RetryOnTimeout": true
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️
note

➖ shows that in Python and Ruby, this behavior is inherently supported by default and cannot be disabled.

Request HTTP Methods to Retry

Use this setting to specify the HTTP methods to retry again. Allowed HTTP verbs are GET and PUT.

Usage

To use this feature, you need to specify a list of HTTP verbs IList<HTTPVerb>. By default, the list contains
[ "GET", "PUT" ] values.

"info": {
...,
"x-codegen-settings": {
"RequestMethodsToRetry": [ "GET", "PUT"]
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️✔️✔️

Status Codes to Retry

Use this setting to specify the HTTP status codes to invoke retry on. Allowed HTTP codes are: "408, 413, 429, 500, 502, 503, 504, 521, 522, 524".

Usage

To use this feature, you need to specify a list of integers IList<int>. By default, the list contains
{ 408, 413, 429, 500, 502, 503, 504, 521, 522, 524 } values.

"info": {
...,
"x-codegen-settings": {
"StatusCodesToRetry": [413, 503, 504]
}
}
note

Only the HTTP codes provided in the list will be retried.

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️✔️✔️

Maximum Retry Wait Time

Use this setting to set the maximum wait time in seconds for overall retrying requests.

Usage

To use this feature, you need to specify an Integer value that represents the wait time in seconds.

"info": {
...,
"x-codegen-settings": {
"BackoffMax": 120
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️

Number of Retries

Use this setting to set the number of retries to make for calling an idempotent endpoint after which the endpoint call should fail.

Usage

To use this feature, you need to specify an Integer value that represents the number of retries. By default, its value is set to 0.

"info": {
...,
"x-codegen-settings": {
"Retries": 3
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️✔️✔️

Retry Interval

Use this setting to set the retry time interval between endpoint calls.

Usage

To use this feature, you need to specify a Float value that represents the time interval. By default, its value is set to 1.0.

"info": {
...,
"x-codegen-settings": {
"RetryInterval": 1.5
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️✔️✔️

User Configurable Retries

Use this setting to decide if your SDK users should be able to configure retries by themselves. Set this setting to true to enable configurable retries and false to disable them.

Usage

To use this feature, you need to specify a Boolean value. By default, its value is set to true.

"info": {
...,
"x-codegen-settings": {
"UserConfigurableRetries": true
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️

Change in SDK

When this setting is enabled, your SDK users will be able to configure timeout and retries in their client as follows:

const client = new Client({
timeout: 60,
httpClientOptions: {
retryConfig: {
maxNumberOfRetries: 3,
retryOnTimeout: true,
retryInterval: 1,
httpStatusCodesToRetry: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
httpMethodsToRetry: ['GET', 'PUT']
}
}
});

Backoff Factor

Use this setting to add an exponential backoff factor to increase interval between retries.

Usage

To use this feature, you need to specify a Float value. By default, its value is set to 2.

"info": {
...,
"x-codegen-settings": {
"BackOffFactor": 1.5
}
}

Language Support

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️✔️✔️