2
votes

I am using a Galaxy 8S android phone with the Samsung SIP settings. I have successfully registered a (Twilio) SIP account on the phone. I want to make an outbound call to an international PSTN Number NOT to another sip address.

My SIP doman, on Twilio, points to my heroku app.

The code is:

@application.route("/makesip", methods=['GET', 'POST'])
def makesip():
    to_number=request.values.get('To', None),
    client = Client(ACCOUNT_SID, AUTH_TOKEN)
    call = client.calls.create(to=to_number, from_="+1415792xxxx", url="https://myapp.herokuapp.com/sipout", method="POST")
    return call.sid
    #return "OK"

@application.route("/sipout", methods=['GET', 'POST'])
def sipout():
    response = VoiceResponse()
    to_number = request.values.get('To', None)
    dial = Dial(caller_id='+1415792xxxx')
    dial.number(to_number)
    response.append(dial)
    return str(response)

When I make the call from my cell phone it hangs up almost immediately and says "Server Error try again later". The Twilio error log says:

We don't support dialing out to global twilio domains (domainname.sip.twilio.com). Only regional (domainname.sip.us1.twilio.com) ones are supported.

I think that I am making a very fundamental error here but I simply cannot identify it. Can anybody help please? Should I, for example, set the "from_" parameter as "sip:my_sip_address.domainname.sip.us1.twilio.com"?

2
Is the 'To' number in full E.164 format? Is it possible that the leading '+' is getting stripped from the number because of being in the url querystring?1.618
yes, no problems there. Thank you.user1903663

2 Answers

2
votes

I'm not a heroku expert, but your code looks similar enough to the php I have running which works fine for this.

In your phone settings is your SIP server set as [email protected] or as [email protected]? It should be the latter. I seem to remember getting caught out by something like this when I was trying to get things working

EDIT

Just had another play with mine and I figured it out. You have to dial the number from your phone as [email protected], then twilio will return to as sip:[email protected]

You need to change this line of your code to strip out just the number

to_number=request.values.get('To', None),

My php line is substr(strtok($to, '@'), 4); so whatever your equivalent of that is.

0
votes

What I think is probably happening is that the "To" that is hitting your Heroku app is in the format "sip:[email protected];user=phone" and you're trying to inject that directly into the "dial" verb.

What you actually want is to strip it down to the bare number in E.194 format (with the leading +).

I'd suggest starting by testing using a quick TwiML Bin as per the Twilio SIP Registration docs, rather than your Heroku app.

TwiML Bins are basically static TwiML but with a tiny bit of intelligence in special tags. It's like the Twilio equivalent of Mail Merge, if you've ever used that in Microsoft Word.

(Twilio recently updated the SIP Registration docs. They're much better now.)

Use a TwiML Bin for initial testing otherwise you risk spending time fixing an otherwise working Heroku app because the problem is your phone/account.

Go to "Twilio Docs > API Reference > Twilio Voice API > SIP Registration".

Scroll down to "Using Enhanced TwiML Bin Templates to Call a mobile/landline on the Public Telephone Network" and follow that.

See if that works.

If it doesn't, my suspicion is your Samsung is actually spitting out something daft due to something dial plan related. (Dial plan is the conversion of +12345645642 into a SIP URI. You might find it's doing something like +012345645642 instead.)

If it does work, great. If you want to get your Heroku app working, compare the working response body to the one your Heroku app is spitting out. Post both, and we'll figure out what's going wrong.

Just to check, you are specifying a region in your Domain and Registration Server settings on the Samsung, yeah? The "yoursipdomain.sip.us1.twilio.com" that miknik talked about?