Configurable callback retries
Plivo sends HTTP webhooks as callbacks during different states of a call and to many URLs, such as answer_url, fallback_url, hangup_url, action, and callback_url. Whenever a failure happens (possibly due to some network issue at the destination server) Plivo retries sending the callback payload to the URLs. For maximum flexibility with webhook callback requests, Plivo offers configurable retry policies that can take over when a webhook request fails due to a destination server issue. This document guides you through the timeout and retry settings for the configurable webhook URLs.
Callback retry scenarios
Having the ability to configure callback retries and timeouts improves reliability and event recovery by letting you:
- Configure a custom timeout based on your use case.
- Set higher timeouts during network problems on your application server.
- Set shorter timeouts during an outage on your application server to ensure faster failover to your fallback URL.
- Enable retries during client-side service interruptions and delays.
To set a nondefault callback retry configuration for any given URL (answer URL, fallback URL, ring URL, etc.), you need to append configuration parameters to it in the form of URL extensions (or ”fragments”) as key-value pairs:
- The first key-value pair should start with #
- Key and value should be separated by =
- Key-value pairs should be separated by &
When Plivo sends an HTTP callback to your webhook URLs during events, you should capture the request (POST or GET based on the type you’ve defined for the URL) and respond with a 200 OK response. When you process the callback, you can store the data in your database.
Plivo automatically retries webhooks for a certain timeframe if an HTTP 200 status code is not returned. The timeframe Plivo has to wait to receive a response from your application server is called a timeout. This table shows the allowed and default timeouts available for webhook URLs.
|ct||Connection timeout||The time in milliseconds (ms) for Plivo to wait while establishing a TCP connection||100 – 10000||2000|
|rt||Read timeout||The time in milliseconds for Plivo to wait:|
— to start receiving a response after sending the initial request
— for delay between packets
|100 – 40000||40000|
|tt||Total timeout||Upper limit on total time allowed for all timeouts, including retries on a given URL (not including fallback URL)||100 – 55000||55000|
Connection timeout of two seconds
Connection timeout of two seconds and a read timeout of three seconds
Plivo lets you configure the number of retries it makes for different webhook URLs and the policy it should use depending on HTTP failure status codes.
|rc||Retry count||Number of retry attempts to be made to the same URL if the initial connection fails (not including to fallback URL)||0 – 5||1|
|rp||Retry policy||Type of failure to retry on:|
4xx → only on 4xx responses
5xx → only on 5xx responses
ct → TCP/TLS connection failures within the connection timeout
rt → no response received within the read timeout
all → all the above
|Comma-separated list of values — for example, rp=ct,rt||ct,rt|
Retry on both connect and read timeout, and reduce the read timeout to three seconds.
Retry on connection failure, but with a two-second connection timeout. If there is no connection in two seconds, retry three times, for a total of four attempts to connect.
Callback retries apply to this list of URLs associated with Plivo’s Voice applications on the console, API requests, and XML elements:
Voice applications on console
- Primary Answer URL
- Fallback Answer URL
- Hangup URL
Callback retry parameters don’t apply to any of these audio URLs:
These URLs use our standard configuration values:
- Connection timeout: 2 seconds
- Read timeout: 120 seconds
- Retry count: 1
- Retry policy: all