AMI Originate fails [SOLVED]

Hello, I’m trying to originate a call over the AMI. When I place a call to some US number from my SIP softphone at 0571 the call goes through. When I try to originate the same call over the AMI I always get 503 “No Circuit Available.”

Can any one tell my why that might be? Thanks much!

I’m using Asterisk 1.4.27.1-1, which is a Vicidial build, but I have customized the setup considerably.

Here are my configs:

extensions.conf (incomplete)

[sandbox]
exten => _.,1,AGI(agi://127.0.0.1)
exten => _.,n,Hangup

[general]
static=yes
writeprotect=no

[globals]
CONSOLE=Console/dsp ; Console interface for demo
TRUNKIAX=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface
TRUNKIAX1=IAX2/ASTtest1:test@10.10.10.16:4569 ; IAX trunk interface
TRUNKloop = IAX2/ASTloop:test@127.0.0.1:40569
TRUNKblind = IAX2/ASTblind:test@127.0.0.1:41569
AIRESPRING = SIP/airespring

[ami-outbound]
exten => 0671,1,Dial(IAX2/0671|60|)
exten => 0671,2,Goto(default,850266666666660671,1)

exten => 0672,1,Dial(IAX2/0672|60|)
exten => 0672,2,Goto(default,850266666666660672,1)

exten => _91XXXXXXXXXX,1,Dial(${AIRESPRING}/${EXTEN:1},tTo)
exten => _91XXXXXXXXXX,n,Hangup

exten => _XXXXXXXXXXX,1,Dial(${AIRESPRING}/${EXTEN},tTo)
exten => _XXXXXXXXXXX,n,Hangup

exten => _XXXXXXXXXX,1,Dial(SIP/${EXTEN}@airespring)
exten => _XXXXXXXXXX,n,Hangup

SIP.conf

[general]
context=default ; Default context for incoming calls
allowoverlap=no ; Disable overlap dialing support. (Default is yes)
bindport=5060 ; UDP Port to bind to (SIP standard port is 5060)
bindaddr=0.0.0.0 ; IP address to bind to (0.0.0.0 binds to all)
srvlookup=yes ; Enable DNS SRV lookups on outbound calls
disallow=all ; First disallow all codecs
allow=ulaw ; Allow codecs in order of preference
allow=gsm
mohinterpret=default
mohsuggest=default
language=en ; Default language setting for all users/peers
relaxdtmf=yes ; Relax dtmf handling
trustrpid = no ; If Remote-Party-ID should be trusted
sendrpid = yes ; If Remote-Party-ID should be sent
progressinband=no ; If we should generate in-band ringing always
dtmfmode = rfc2833 ; Set default dtmfmode for sending DTMF. Default: rfc2833
videosupport=no ; Turn on support for SIP video. You need to turn this on
callevents=yes ; generate manager events when sip ua
rtpkeepalive=60 ; Send keepalives in the RTP stream to keep NAT open
notifyringing = yes ; Notify subscriptions on RINGING state (default: no)
notifyhold = yes ; Notify subscriptions on HOLD state (default: no)
limitonpeers = yes ; Apply call limits on peers only. This will improve
localnet=192.168.0.0/255.255.0.0; All RFC 1918 addresses are local networks
localnet=10.0.0.0/255.0.0.0 ; Also RFC1918
localnet=172.16.0.0/12 ; Another RFC1918 with CIDR notation
localnet=169.254.0.0/255.255.0.0 ;Zero conf local network
nat=yes ; Global NAT settings (Affects all peers and users)
canreinvite=no ; Asterisk by default tries to redirect the
jbenable = yes ; Enables the use of a jitterbuffer on the receiving side of a
jbforce = no ; Forces the use of a jitterbuffer on the receive side of a SIP
jbmaxsize = 100 ; Max length of the jitterbuffer in milliseconds.
jbresyncthreshold = 1000 ; Jump in the frame timestamps over which the jitterbuffer is
jbimpl = fixed ; Jitterbuffer implementation, used on the receiving side of a SIP
jblog = no ; Enables jitterbuffer frame logging. Defaults to “no”.
qualify=yes ; By default, qualify all peers at 2000ms
limitonpeer = yes ; enable call limit on a per peer basis, different from limitonpeers
register => 65.XX.XX.XX

[airespring]
type=peer
host=65.XX.XX.XX
dtmfmode=rfc2833
fromdomain=63.XX.XX.XX
context=default
insecure=very
dtmfmode=rfc2833
disallow=all
canreinvite=no
allow=ulaw,g729
qualify=1000

[0572]
username=0572
secret=2234test
accountcode=0572
callerid="mthorley"
mailbox=0572
context=default
type=friend
host=dynamic

[0571]
username=0571
secret=1234test
accountcode=0571
callerid=“Davey” <8012223333>
mailbox=0571
context=default
type=friend
host=dynamic

IAX.conf

[general]
bindport=4569 ; bindport and bindaddr may be specified
bindaddr=0.0.0.0 ; more than once to bind to multiple
delayreject=yes
adsi=no
language=en
mohinterpret=passthrough
mohsuggest=default
disallow=all
allow=ulaw
allow=gsm
jitterbuffer=yes
forcejitterbuffer=no
maxjitterbuffer=1000
maxjitterinterps=10
resyncthreshold=1000
trunkfreq=20 ; How frequently to send trunk msgs (in ms)
trunktimestamps=yes
minregexpire = 60
maxregexpire = 360
iaxthreadcount = 50
iaxmaxthreadcount = 250
authdebug=no
regcontext=default
autokill=yes
codecpriority=host
allowfwdownload=no
register => ASTloop:test@127.0.0.1:40569
register => ASTblind:test@127.0.0.1:41569

[ASTloop]
accountcode=ASTloop
secret=test
type=friend
requirecalltoken=no
context=default
auth=plaintext
host=dynamic
permit=0.0.0.0/0.0.0.0
disallow=all
allow=ulaw
qualify=yes

[ASTblind]
accountcode=ASTblind
secret=test
type=friend
requirecalltoken=no
context=default
auth=plaintext
host=dynamic
permit=0.0.0.0/0.0.0.0
disallow=all
allow=ulaw
qualify=yes

[0671]
type=friend
context=default
host=dynamic
secret=1234test

[0672]
type=friend
context=default
host=dynamic
secret=1234test
requirecalltoken=no

Here is the relevant log output

Soft phone outbound success

-- Executing [801839XXXX@default:1] AGI("SIP/0571-00000004", "agi://127.0.0.1:4577/call_log") in new stack
-- AGI Script [agi://127.0.0.1:4577/call_log](agi://127.0.0.1:4577/call_log) completed, returning 0
-- Executing [801839XXXX@default:2] Dial("SIP/0571-00000004", "SIP/airespring/801839XXXX||tTo") in new stack
-- Called airespring/801839XXXX
-- SIP/airespring-00000005 is making progress passing it to SIP/0571-00000004
-- Executing [h@default:1] DeadAGI("SIP/0571-00000004", "agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----0-----CANCEL- ...

AMI call fail (SIP channel)

-- Executing [801839XXXX@default:1] AGI("SIP/0571-00000009", "agi://127.0.0.1:4577/call_log") in new stack
-- AGI Script [agi://127.0.0.1:4577/call_log](agi://127.0.0.1:4577/call_log) completed, returning 0
-- Executing [801839XXXX@default:2] Dial("SIP/0571-00000009", "SIP/airespring/801839XXXX||tTo") in new stack
-- Called airespring/801839XXXX
-- Got SIP response 503 "No Circuit Available" back from 65.XX.XX.XX
-- SIP/airespring-0000000a is circuit-busy
-- Executing [801839XXXX@default:3] Hangup("SIP/0571-00000009", "") in new stack
-- Executing [h@default:1] DeadAGI("SIP/0571-00000009", "agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----34-----CONGEST ...
-- AGI Script [agi://127.0.0.1:4577/call_log--HVcauses ... ----------](agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----34-----CONGESTION----------) completed, returning 0

The AMI call looks like this:

chan = "SIP/0571"
extn = “801839XXXX”

r = ami.send_action “Originate”, {
“Channel” => chan,
“Exten” => extn,
“Priority” => 1,
“Context” => “default”}

Thanks to all for taking the time to look at this.

The AMI call was failing because my provider, Airespring, requires the CallerID to be set for outbound calls.

I change my AMI call to this, and now it works:

chan = "IAX2/0671"
extn = “801XXXXXXX”

r = ami.send_action “Originate”, {
“Channel” => chan,
“Exten” => extn,
“Priority” => 1,
“Context” => “default”,
“Callerid” => “‘Davey’ <801ZZZZZZZ>”
}