Unable to Make SIP Calls from Asterisk to External IP

Hi All,

I have an Asterisk server running on Ubuntu.

My call flow is as follows: I call the Twilio SIP trunk, and under that SIP trunk, I call my Ubuntu server’s IP address, and the call successfully reaches my Ubuntu server. After that, I need to call this IP address:

075a565fd26a@xx.xx.537.214?X-code1=9&X-code2=35&X-pin=#PIN

I am doing it like this:

[from-twilio] in extention.conf

exten => +44xxxxxxxxxx,1,NoOp(— CALL STARTED —)
exten => +44xxxxxxxxxx,n,NoOp(Call received from Twilio for +44xxxxxxxxxx)
exten => +44xxxxxxxxxx,n,NoOp(Handling first call)
exten => +44xxxxxxxxxx,n,Set(PJSIP_HEADER(add,X-code1)=9)
exten => +44xxxxxxxxxx,n,Set(PJSIP_HEADER(add,X-code2)=35)
exten => +44xxxxxxxxxx,n,Set(PJSIP_HEADER(add,X-pin)=1234566)
exten => +44xxxxxxxxxx,n,Dial(PJSIP/075a275ea2fa@xx.xx.537.214)
exten => +44xxxxxxxxxx,n,NoOp(Direct call status: ${DIALSTATUS})
exten => +44xxxxxxxxxx,n,Hangup()

In the logs, I can see — CALL STARTED —, and the device I’m calling says “line temporarily busy.”

When I try a direct call from Twilio, like this, it works and responds:

$ServerSIP = “sip:075a565fd26a@xx.xx.537.214?headers”;

header(‘Content-Type: application/xml’);
echo “<?xml version=\"1.0\" encoding=\"UTF-8\"?>”;
echo “”;
echo “”;
echo “{$ServerSIP}”;
echo “”;
echo “”;

I am new to Asterisk, so please help me figure out how I can call that IP address.

Thanks!

See the third example in Dialing PJSIP Channels - Asterisk Documentation mytrunk is needed to define things like transports and codec choices.

This is also incorrect. You have to invoke a pre-dial handler[1].

[1] PJSIP_HEADER - Asterisk Documentation

Hi thanks for reply

I did this But still not working

[from-twilio]

exten => +44xxxxxxxxx,1,NoOp(— CALL STARTED —)

same => n,Dial(PJSIP/twilio_outbound/sip:${EXTEN}@xx.xx.537.214:5060,b(set-headers^addheader^1)) ; Dial the en>

same => n,NoOp(Call result: ${DIALSTATUS})

same => n,Hangup()

[set-headers]

exten => addheader,1,Set(PJSIP_HEADER(add,X-code1)=9)

same => n,Set(PJSIP_HEADER(add,X-code2)=35)

same => n,Set(PJSIP_HEADER(add,X-pin)=12345466)

same => n,Return()

and in Pjsip

[twilio_outbound]

type=endpoint

transport=transport-udp

context=from-internal

disallow=all

allow=ulaw,alaw

aors=twilio_outbound_aor

outbound_auth=twilio_auth

direct_media=no

[twilio_outbound_aor]

type=aor

contact=sip:xx.xx.537.214:5060

What does not working mean? What happens?

Your output doesn’t match the configuration you’ve provided.

This is the from-sip context, but you’ve provided from-twilio.

From Twilio is for receiving the call from Twilio SIP and then forwarded to a third party

I not sure what I need to configure for third party

You’ll need to provide SIP output as well using “pjsip set logger on” of an attempt.

This is not responding to the SIP INVITE.

Why that is, no idea.

My answer doesn’t really change. Asterisk is sending the SIP INVITE but getting no response. I don’t know what is on the other side, what it is expecting, why it is not answering, or if configuration is wrong.

Get clarification from the other side?

I am not sure what I should ask ?

I would provide the SIP INVITE you have sent them, and ask them what is incorrect with it.

Ok please
Thanks

Is it possible that they haven’t allowed my IP address?
Or could it be due to some kind of restriction — for example, my server is calling their SIP endpoint and receiving a 500 response?
Could this be because of a restriction on their side, or do they need to open any ports for me?
If that’s the case, how can I confirm this from my side?

I can’t speak for them, I can only say Asterisk sent a SIP INVITE. It got no response. It didn’t get a 500 response. It got none.

Ok then what about my configuration these are all fine ?

I don’t know who you are connecting to or what they are expecting, so I can’t answer that. I can only say that they work resulting in a SIP INVITE going out.