Increase Twilio Total Timeout from 15000ms - SMS - twilio

When an API call is made after receiving an SMS via Twilio, I occasionally get the error below -
Error: Total timeout is triggered. Configured tt is 15000ms and we attempted 1 time(s)
The API call occasionally takes longer than 15 seconds to return a response (this is due to having to process the SMS etc.). How can I configure the total timeout to say 25000ms?

It is possible to override the timeout settings for a webhook. However, the maximum total time (tt) for webhooks is 15 seconds and you cannot increase it beyond there.
If you find your service cannot respond within that time, you might want to hand off the processing of the SMS to a job and respond to the webhook quicker. If you then intend to reply to the SMS, you can do so using the REST API message resource instead of TwiML.

Related

Is there a Twilio outbound SMS magic number that hits a timeout value?

I'm testing some flows that use outbound SMS via Twilio and have been really pleased and impressed by the magic numbers provided e.g. https://www.twilio.com/docs/iam/test-credentials
However, I'm interested to see how our application responds if there's some issue sending an SMS to a number where it essentially hits a timeout value. I haven't found a magic number such as this or know of a way to recreate the scenario, can anyone help me here?
Even if you were using a real auth credentials and real phone number (instead of magic number), I suspect Twilio just queues the request on their side and responds with a HTTP 201, so you'll always get a very fast response from Twilio, but it doesn't necessarily mean the message has been sent to a carrier and delivered to a device.
If you're using Twilio messaging services, you can subscribe to delivery status callbacks to get the status of a SMS e.g. sending, sent, delivered, failed, etc - see here. Note: I don't know if you'd receive callbacks with magic numbers - I suspect not... either way you can provision a Twilio phone number pretty cheaply to test e.g. in Australia (where I'm from) I can purchase a AU phone number for $6 per month and I can release the phone number when ever I want to stop getting billed for it...
If you just want your app to timeout on invocation of the Twilio API you can do something like the following (in .NET core) to force timeout a request in a specified amount of time (1 second in example below):
using var tokenSource = new CancellationTokenSource(TimeSpan.FromMilliseconds(1000));
response = await twilioHttpClient.PostAsJsonAsync($"2010-04-01/Accounts/{accountSID}/Messages.json", request, jsonSerializerOptions, tokenSource.Token);
If timeout is exceeded, an exception will be thrown that you can handle. Note: there's various networking tools that can be used to block or limit outbound requests, which you can use to test timeout scenarios.

Too Many Requests in sending Bulk Messages using Twilio Message Service

I am getting the error below when I send bulk messages using Twilio Message Service.
[HTTP 429] Unable to create record: Too Many Requests
I have around 50 numbers in the sender pool in this Message Service.
And I am trying to send about 5K messages at once, some delays are Okay,
But the messages couldn't be sent due to this error,
Thanks in advance,
Twilio developer evangelist here.
A 429 error means that you are exceeding the number of concurrent connections to the Twilio API. By default, this is 100, though it can vary depending on your account.
To counteract this, you should aim to make less than 100 concurrent requests to the API and implement retries with an exponential back off to allow for your other requests to finish.
There is more information on the 429 error here including further links for implementing the above strategies.

603 Declined event is coming while hangup on incoming call with sipML5 but after 4-5 sec again I am getting incoming call

I am using asterisk 15.5 as voip server and twillio trunk to make outgoing and incoming call but when I hangup on an incoming call to sip client then 603 Declined event is coming to asterisk but after 4-5 sec again I am getting incoming call repeatedly. is it the issue with twilio trunk or 603 delined does not getting propogated?
You can go under your Twilio Call Logs, click the particular Call(Sid) in question, and view the public packet capture (pcap), to see what Asterisk is sending back to Twilio. Twilio should not be resending the INVITE / advancing to the next origination URI (if configured) if receiving a 603 response from Asterisk, so most likely Asterisk is sending some other response code. You could also look at Asterisk logs to determine same.
Source: https://www.twilio.com/docs/sip-trunking#multiple-orig-uris
"Note: If any of the following SIP status codes are returned ("2xx", "400", "404", "405", "410", "416", "482", "484", "486", "6xx"), Twilio will not fail over to the next origination SIP URI. If there is no SIP response from a given server, Twilio will fail over after 4 seconds."
It is possible the carrier is retrying. You should be able to see this if there are multiple CallSID's which indicates the carrier sent it to Twilio multiple times.

Twilio Child Call Status incorrect?

I'm experimenting with Twilio and I'm confused a bit by the ultimate status of my calls.
Here's what I'm doing. I'm making a call to a Twilio Phone Number which is hooked into an application endpoint. The app makes a database record of the call and then uses Twiml to make a secondary call out to another phone. After the call is complete, the call record is updated with data retrieved from Twilio then a secondary call record is created from the call in my account where its parent_call_sid is my original call's sid.
My issue is, if I call the Twilio Number but let the Twiml Dial timeout, the child call status ends up being 'completed' instead of 'no-answer'.
My question is why is this happening? Do I need to configure how I dial out differently in order to receive the appropriate status for my calls?
UPDATE:
This has been resolved. The issue was voicemail picking up before Twilio's default timeout of 30 seconds ended the call, resulting in a 'completed' status. By reducing the timeout Twilio was able to end the call with 'no-answer' before the voice mail picked up.
The issue was the timeout was long enough for the voice mail to pick up, which does not count as no-answer. Reducing the Timeout so that Twilio ends the call before voice mail answers correctly results in a no-answer status.

How many times Twilio will try sending texts to a number which has been, out of range, network disconnected?

I am trying to understand before twilio generated error #30003, how many times it tried reaching the end cellphone #, if the subscriber's cell phone is out of range, not available? switched off, temporary disconnected and so on?
Twilio developer here.
Twilio only spends a few seconds trying to deliver an SMS message before determining that the message delivery failed. The exact amount of time varies based on which carrier is used for the delivery.
So if your first attempt to deliver a message failed but you want to try again later, you should add some logic to your application that resends the message to Twilio at a time that makes sense.
Note that Twilio does not charge you for failed attempts to send a message.
Let me know if that helps!

Resources