[asterisk-users] Failover SIP logic

Jeremy Mann jmann at txhmg.com
Mon Sep 10 10:12:21 CDT 2007


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.




More information about the asterisk-users mailing list