I need some extensions logic assistance, I'm trying to dial out one of
multiple SIP trunks, in sequence. I need to detect a busy SIP trunk(I only
allow 1 call per trunk) and roll over to a second or third depending on that
busy status
Here's what I've got for a macro thusfar, but it's not working(fails
if the 1st trunk is busy)
extensions.conf:
[globals]
trunk_1 => SIP/trunk1
trunk_2 => SIP/trunk2
trunk_3 => SIP/trunk3
[macro-trunkdial]
exten => s,1,Dial(${trunk_1}/${ARG1})
exten => s,2,Hangup()
exten => s,102,Dial(${trunk_2}/${ARG1})
exten => s,103,Hangup()
exten => s,203,Dial(${trunk_3}/${ARG1})
exten => s,204,Hangup()
[from-internal]
exten => _NXXNXXXXXX,1,Macro(trunkdial,+1${EXTEN})
exten => _1NXXNXXXXXX,1,Macro(trunkdial,+${EXTEN})
sip.conf:
[trunk1]
host=xxx.xxx.xxx.xxx
port=5060
type=peer
allow=ulaw
dtmfmode=rfc2833
canreinvite=no
reinvite=no
nat=no
fromuser=+xxxxxxxxxxx
call-limit=1
[trunk2]
host=xxx.xxx.xxx.xxx
port=5060
type=peer
allow=ulaw
dtmfmode=rfc2833
canreinvite=no
reinvite=no
nat=no
fromuser=+xxxxxxxxxxx
call-limit=1
[trunk3]
host=xxx.xxx.xxx.xxx
port=5060
type=peer
allow=ulaw
dtmfmode=rfc2833
canreinvite=no
reinvite=no
nat=no
fromuser=+xxxxxxxxxxx
call-limit=1
Here's asterisk output when someone dials out:
Executing [xxxxxxxxxx at from-internal:1] Macro("SIP/6001-007e2840",
"trunkdial|+1xxxxxxxxxx") in new stack
-- Executing [s at macro-trunkdial:1] Dial("SIP/6001-007e2840",
"SIP/trunk1/+1xxxxxxxxxx") in new stack
[Sep 10 09:06:52] ERROR[16253]: chan_sip.c:3192 update_call_counter: Call to
peer 'trunk1' rejected due to usage limit of 1
-- Couldn't call trunk1/+1xxxxxxxxxx
== Everyone is busy/congested at this time (0:0/0/0)
-- Executing [s at macro-trunkdial:2] Hangup("SIP/6001-007e2840",
"") in new stack
I don't want the dialplan to cascade like:
exten => 1,dial...
exten => 2,dial...
Because if the remote end hangs up I don't want it going to priority 2 to
dial out again(in case my user doesn't hit hang-up on their end) so I need
logic to detect a busy channel and jump to the next section..
Thanks for any help.
This e-mail, facsimile, or letter and any files or attachments transmitted with
it contains information that is confidential and privileged. This information is
intended only for the use of the individual(s) and entity(ies) to whom it is
addressed. If you are the intended recipient, further disclosures are prohibited
without proper authorization. If you are not the intended recipient, any
disclosure, copying, printing, or use of this information is strictly prohibited
and possibly a violation of federal or state law and regulations. If you have
received this information in error, please notify Texas Health Management Group
immediately at 1-817-310-4999. Texas Health Management Group, its subsidiaries,
and affiliates hereby claim all applicable privileges related to this
information.
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
X-ECN Telecoms-MailScanner-Information: Please contact ECN Telecoms for more information X-ECN Telecoms-MailScanner: Found to be clean X-ECN Telecoms-MailScanner-From: yusuf at ecntelecoms.com X-Spam-Status: No Jeremy Mann wrote:> I need some extensions logic assistance, I'm trying to dial out one of multiple SIP trunks, in sequence. I need to detect a busy SIP trunk(I only allow 1 call per trunk) and roll over to a second or third depending on that busy status > > Here's what I've got for a macro thusfar, but it's not working(fails if the 1st trunk is busy) > extensions.conf: > > [globals] > trunk_1 => SIP/trunk1 > trunk_2 => SIP/trunk2 > trunk_3 => SIP/trunk3 > > [macro-trunkdial] > exten => s,1,Dial(${trunk_1}/${ARG1}) > exten => s,2,Hangup() > exten => s,102,Dial(${trunk_2}/${ARG1}) > exten => s,103,Hangup() > exten => s,203,Dial(${trunk_3}/${ARG1}) > exten => s,204,Hangup() > > [from-internal] > exten => _NXXNXXXXXX,1,Macro(trunkdial,+1${EXTEN}) > exten => _1NXXNXXXXXX,1,Macro(trunkdial,+${EXTEN}) > > sip.conf: > > [trunk1] > host=xxx.xxx.xxx.xxx > port=5060 > type=peer > allow=ulaw > dtmfmode=rfc2833 > canreinvite=no > reinvite=no > nat=no > fromuser=+xxxxxxxxxxx > call-limit=1 > > [trunk2] > host=xxx.xxx.xxx.xxx > port=5060 > type=peer > allow=ulaw > dtmfmode=rfc2833 > canreinvite=no > reinvite=no > nat=no > fromuser=+xxxxxxxxxxx > call-limit=1 > > [trunk3] > host=xxx.xxx.xxx.xxx > port=5060 > type=peer > allow=ulaw > dtmfmode=rfc2833 > canreinvite=no > reinvite=no > nat=no > fromuser=+xxxxxxxxxxx > call-limit=1 > > Here's asterisk output when someone dials out: > Executing [xxxxxxxxxx at from-internal:1] Macro("SIP/6001-007e2840", "trunkdial|+1xxxxxxxxxx") in new stack > -- Executing [s at macro-trunkdial:1] Dial("SIP/6001-007e2840", "SIP/trunk1/+1xxxxxxxxxx") in new stack > [Sep 10 09:06:52] ERROR[16253]: chan_sip.c:3192 update_call_counter: Call to peer 'trunk1' rejected due to usage limit of 1 > -- Couldn't call trunk1/+1xxxxxxxxxx > == Everyone is busy/congested at this time (0:0/0/0) > -- Executing [s at macro-trunkdial:2] Hangup("SIP/6001-007e2840", "") in new stack > > I don't want the dialplan to cascade like: > > exten => 1,dial... > exten => 2,dial... > > Because if the remote end hangs up I don't want it going to priority 2 to dial out again(in case my user doesn't hit hang-up on their end) so I need logic to detect a busy channel and jump to the next section..If you have this: exten => _X.,1,Dial(SIP/trunk1) exten => _X.,2,Dial(SIP/trunk2) exten => _X.,3,Dial(SIP/trunk3) then, only if trunk is busy, will it go to trunk2, if thats busy, it will go to trunk 3. Reason is, is that control wont return to the dial plan(except h) if the call was successfull. SO if the call went through on trunk 1, then it will exit, not dial trunk2 or trunk3. So this dial plan will work. But its very sequential, i.e. will try trunk1, then trunk2, then trunk3. If you want to replicate round-robin, r, then do this: [globals] IPt=trunk1-trunk2-trunk3 COUNTt=0 NoOfChannels=3 [just-an-idea] exten => _XXXXXXXXX.,1,Gotoif($["${COUNTt}" = "${NoOfChannels}"] ? 2:3) exten => _XXXXXXXXX.,2,SetGlobalVar(COUNTt=0]) exten => _XXXXXXXXX.,3,SetGlobalVar(COUNTt=$[${COUNTt}+1]) exten => _XXXXXXXXX.,4,Set(tr=${CUT(IPt,-,${COUNTt})}) exten => _XXXXXXXXX.,5,Dial(SIP/tr/${EXTEN}) modify at your leisure. So if you get a few more trunks, you just change "NoOfChannels" -- thanks, Yusuf
Ciao Jeremy,> I need some extensions logic assistance, I'm trying to dial out one of > multiple SIP trunks, in sequence. I need to detect a busy SIP trunk(I only > allow 1 call per trunk) and roll over to a second or third depending on that > busy status > > Here's what I've got for a macro thusfar, but it's not working(fails if the > 1st trunk is busy) extensions.conf: > > [globals] > trunk_1 => SIP/trunk1 > trunk_2 => SIP/trunk2 > trunk_3 => SIP/trunk3 > > [macro-trunkdial] > exten => s,1,Dial(${trunk_1}/${ARG1}) > exten => s,2,Hangup() > exten => s,102,Dial(${trunk_2}/${ARG1}) > exten => s,103,Hangup() > exten => s,203,Dial(${trunk_3}/${ARG1}) > exten => s,204,Hangup()Which asterisk version are you using? IIRC, priority jumping (ie. going to n+101) was disabled by default in some 1.2.x version. You should rely on DIALSTATUS. See Dial() page in voip-info.org. HTH, -- Dr. Andrea Spadaccini Multimedia Technologies Institute - MTI S.r.l. Web: www.x-voice.it - Tel: +39 (0) 95 7224945