Timeouts & Retries¶
Timeout values in the KX Sensors SAPI are used to limit the execution time for an operation. Operations are aborted if they do not complete within the specified time and a response is returned with a response code (RC) of TIMEOUT.
Per failed attempt, the wait time is multiplied by the configured scaling factor, which defaults to 1.
Note: if a retryable response is received from the server, the client issues the next attempt right away, without applying the retryInterval.
Retry policy structure¶
| Configuration variable | Description |
|---|---|
| maxAttempts | Maximum number of attempts before a timeout is triggered |
| timeout | Timeout for the completion of a single attempt (in milliseconds) |
| retryInterval | Interval between attempts (in milliseconds) |
| retryScaling | Retry interval scaling factor; the value must be >= 1 |
Example Retry Execution¶
For example, given the following parameters:
maxAttempts:5retryInterval:5000retryScaling:1.2
Here is an example execution:
- 1st attempt: No wait time
- 2nd attempt: Wait
5,000 ms - 3rd attempt: Wait
5,000 ms × 1.2 = 6,000 ms - 4th attempt: Wait
6,000 ms × 1.2 = 7,200 ms - 5th attempt: Wait
7,200 ms × 1.2 = 8,640 ms - Operation fails after 5th attempt.
Specifying a server timeout for the operation¶
To specify timeouts for server operations; the following attribute should be added to the header object:
| Field | Type | Description |
|---|---|---|
timeout |
int | Timeout for the server operation of a single attempt (in seconds) |
Note: the unit for a server timeout has to be specified in seconds.