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. To enable users to optimize for lower latency and build fault tolerance into webhook interactions, Plivo offers optional parameters that let developers configure timeouts (the timeframe Plivo has to wait to receive a response from your application server), retry policy, and edge region from which the webhook request is sent to the URL. Regions correspond to Plivo points of presence (PoP).
Having the ability to configure callback retries and timeouts improves reliability and event recovery by letting you:
To set callback configurations 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.
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.
An edge region is the geographical region from which Plivo initiates an HTTP webhook to the answer_url, fallback_url, hangup_url, action, or callback_url URLs. Plivo maintains edge clusters in four regions:
To ensure minimum latency, Plivo automatically chooses the nearest region for all callbacks we initiate, but developers can configure the region for each URL using the
|er||Edge Region||Specifies the edge region where webhooks get initiated from. This parameter needs to be either a selection strategy or a specific region.
Region Selection Strategies:
nearest → selects the region geographically closest to the location of the URL.
local → selects the same region as the media server where the call media is hosted.
n_california, n_virginia, frankfurt, singapore
The HTTP webhook to this URL from Plivo will be initiated from Plivo’s North California edge region.
The HTTP webhook to this URL from Plivo will be initiated from the Plivo’s edge region that is nearest to the location of the URL.
Callback retries apply to this list of URLs associated with Plivo’s Voice applications on the console, API requests, and XML elements:
Callback retry parameters don’t apply to any of these audio URLs:
These URLs use our standard configuration values: