Use Transfer, with a SIP: URI, after the call is answered.
Note this is the first I’ve heard this of Twilio. Other providers use redirection headers to indicate that an outgoing leg is the result of an incoming leg, so should have had its CLI forwarded. However I have no personal experience of doing this.
I actually thought it was uncommon for providers to support REFER>
Cant use sip:URI schema, because the number I want to forward to is not behind sip.
from twilio docu:
Call Transfer to the PSTN
In order to transfer a call to the PSTN you must include your Trunking Termination Domain for example sip:+14152908007@{my-trunk}.pstn.twilio.com or alternatively use a Tel-URI for example tel:+14152909007 in the Refer-To header.
so, thats the reason, why I’m trying to use tel schema here, because the number I’m trying to forward to is not under sip…
just for understanding
I have a number on sip trunk, where the originating call is coming
asterisk receives that call and because nobody can answer that call should be transfered to another number.
you say, that that another number should be on a sip trunk in twilio. If so, twilio will send it to asterisk again and I’ll end in a infinite loop.
Twilio would only send it to Asterisk again, possibly, if you tell it to redirect the call to a number that is routed to Asterisk. If you SIP REFER to a number that is not yours, then Twilio would presumably just send the call within their infrastructure and you would have no further knowledge of it.
call is processed by asterisk again, but the DID is not the configured one, so asterisk answers with a message “the number you are calling is not in use”.
I desperatly trying to configure reliable call forward, but I dont know anymore where to look.
my custom extension configuration looks like this:
what I observe here, is, the asterisk replies with 302 Moved Temporary, instead of SIP REFER and uses Contact the number I want, BUT always with the IP from the asterisk server.
302 is because the call has not been answered. REFER can only be used for answered calls. Other people seem to be asking questions based on wanting to use 302 with Twilio.
I’m surprised that the domain name is being resolved. That looks wrong to me.
You haven’t said what 194.XXX.XX.143 represents and you have obfuscated both domain and IP sufficiently that I can’t work that out by doing DNS lookups.
I wonder if you have rewrite_contact and there is a bug causing it to rewrite every contact, not just those it should overwrite. If so note that none of the NAT hacks (rewrite_contact, force_rport, and symmetric_media) should be needed when using a competent provider. They should only be needed when accessing phones which can’t be properly configured for use behind NAT. Normal providers should only be outside NAT, not behind it.
and similar question regarding contact field just a moment ago, with your reference to documentation for redirect method: Asterisk not redirecting calls properly
I think that Twilio will be happy with 302, if they accept redirects, at all. Strangely, you answer the call by calling Answer(), or as a side effect of some other applications, but note that answering will start the billing clock, for the caller, if the call is chargeable.
The other thread is about incoming redirects, not outgoing ones, unless I read it wrongly. My answer was about incoming ones. Incoming redirect => outgoing call.
I’ve run the wireshark on the other thread and it is definitely an incoming (302) redirection, so my answer, on that one, stands. Also note on that one that the unexpected IP address is not that of Asterisk.
You didn’t answer the implied question as to whether you had rewrite contact set. As noted, this should not be required for competent ITSPs.
It occurs to me that, if Asterisk is inappropriately applying rewrite_contact to the Contact header in 302 responses, that could explain, although not justify, the original crash, as it could mishandle the missing “@” in the tel: URI, and try to replace a domain that didn’t exist, in the first place.
If that is the case going through the proper crash reporting process (including backtraces from a non-optimised build) might show the crash to be in the rewrit_contact code, although sometimes such errors produce a delayed crash.
The rewrite_contact option is not applied in that scenario, and it has protection against non-SIP/SIPS based URIs. It would be the external_signaling_address option on transport that would be applied, and it also has protection. There is also an issue where external_signaling_address is applied to the Contact on requests/responses it shouldn’t be, specifically when using Transfer().
An issue can certainly be filed with a backtrace, but there’s no guarantee of if/when it would be looked at and resolved.