- What: Configure webhook timeout, retry policy, and edge region for Plivo voice callbacks
- How: Append URL fragments to callback URLs (e.g.,
answer_url#plivo_timeout=5000&plivo_retries=3) - Defaults: Connection timeout = 2s, read timeout = 40s, retry count = 1
- Limitation: Only applies to
answer_url,fallback_url,hangup_url,action,callback_url. Does NOT apply to audio URLs (Play/PreAnswer XML)
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.
Configuration mechanism
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.- The first key-value pair should start with #
- Key and value should be separated by =
- Key-value pairs should be separated by &
Note: If you don’t append any parameters, the default values from the tables below will apply.
Timeouts
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.Examples
-
https://example.com/answer_url?query=123#ct=2000
Connection timeout of two seconds -
https://example.com/answer_url?query=123#ct=2000&rt=3000
Connection timeout of two seconds and a read timeout of three seconds
Retries
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.Note: If a partial response is received from your app server, Plivo will not make a retry attempt.
Examples
-
https://example.com/answer_url?query=123#rt=3000&rp=ct,rt
Retry on both connect and read timeout, and reduce the read timeout to three seconds. -
https://example.com/answer_url?query=123#rc=3&ct=2000
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.
Edge Region
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:- North California (United states)
- North Virginia (United States)
- Frankfurt (Germany)
- Singapore
- Mumbai (India)
er parameter:
Examples
-
https://example.com/answer_url?query=123#er=n_california
The HTTP webhook to this URL from Plivo will be initiated from Plivo’s North California edge region. -
https://example.com/answer_url?query=123#er=nearest
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.
Applicable URLs
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
API
Make a call:- answer_url
- ring_url
- hangup_url
- fallback_url
- machine_detection_url
- aleg_url
- bleg_url
- transcription_url
- callback_url
- transcription_url
- callback_url
XML
Dial:- action
- confirmSound
- dialMusic
- callbackUrl
- action
- callbackUrl
- waitSound
- action
- interimSpeechResultsCallback
- action
- action
- transcriptionUrl
- callbackUrl
Inapplicable URLs
Callback retry parameters don’t apply to any of these audio URLs:API
Play audio on a callPlay audio to a conference member
XML
PreAnswer XMLPlay XML These URLs use our standard configuration values:
- Connection timeout: 2 seconds
- Read timeout: 120 seconds
- Retry count: 1
- Retry policy: all