Multi SIP Trunk w/ Round Robin in Vicidial

Any and all non-support discussions

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

Multi SIP Trunk w/ Round Robin in Vicidial

Postby joaosp » Mon Mar 28, 2011 7:31 am

Hello,

I've been searching quite a while and doing some code, and I was able to get working a multi-trunk w/ round robin in Vicidial (GoAutoDial 2.0).

I will share it here because I searched alot here and couldn't find any straight answer.

1st. Configure your SIP trunks in sip.conf

Example based on my provider:

register => +3513020XXXXX@voip.telepac.pt:SECRET:+3513020XXXXX@proxy.voip.telepac.pt:5060/+3513020XXXXX

register => +3513020XXXXX@voip.telepac.pt:SECRET:+3513020XXXXX@proxy.voip.telepac.pt:5060/+3513020XXXXX

[Trunk1]
disallow=all
#nat=yes
canreinvite=yes
context=from-trunk
from=+3513020XXXXX
fromdomain=voip.telepac.pt
host=voip.telepac.pt
insecure=port,invite
outboundproxy=proxy.voip.telepac.pt
port=5060
qualify=yes
secret=SECRET
type=friend
username=+3513020XXXXX
authname=+3513020XXXXX
fromuser=+3513020XXXXX
dtmfmode=rfc2833
allow=ulaw
allow=alaw
registername=+3513020XXXXX
call-limit=1

[Trunk2]
disallow=all
#nat=yes
canreinvite=yes
context=from-trunk
from=+3513020XXXXX
fromdomain=voip.telepac.pt
host=voip.telepac.pt
insecure=port,invite
outboundproxy=proxy.voip.telepac.pt
port=5060
qualify=yes
secret=SECRET
type=friend
username=+3513020XXXXX
authname=+3513020XXXXX
fromuser=+3513020XXXXX
dtmfmode=rfc2833
allow=ulaw
allow=alaw
registername=+3513020XXXXX
call-limit=1

Now in extensions.conf

[general]
Trunk1=SIP/Trunk1
Trunk2=SIP/Trunk2


IPt=Trunk1-Trunk2 '(place here all your trunks separated by '-')'
COUNTt=0
NoOfChannels=2 '(change to match the number of trunks that you are using)'

[default]

exten => _XXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _XXXXXXXXX,2,Gotoif($["${COUNTt}" = "${NoOfChannels}"] ? 3:4)
exten => _XXXXXXXXX,3,SetGlobalVar(COUNTt=0])
exten => _XXXXXXXXX,4,SetGlobalVar(COUNTt=$[${COUNTt}+1])
exten => _XXXXXXXXX,5,SetGlobalVar(tr=${CUT(IPt,-,${COUNTt})})
exten => _XXXXXXXXX,6,Dial(SIP/${EXTEN}@${tr},15,o)
exten => _XXXXXXXXX,7,Hangup

This will use all your available and registered trunks in a round-robin fashion, making you able to use multiple SIP trunks in one campaign, very usefull for unlimited SIP accounts or SIP accounts with 1 max call.

Hope its usefull, and if any1 has any sugestions please post.

Cheers :)
joaosp
 
Posts: 5
Joined: Mon Mar 28, 2011 7:19 am

Postby williamconley » Mon Mar 28, 2011 7:10 pm

this is your FIRST post?

i can't wait for the second 8)

ordinarily i have to tell people to post their installer/vicidial version etc to get help.

in your case however, I will state WHERE each of these items COULD go to avoid modifying the .conf files directly with an editor, should you wish to do so 8) (one of the major goals of the system is to avoid using ssh and editing configuration files, in part to allow ALL customizations to reside inside the mysql tables, thus making them "configuration" instead of "customization", and upgrade/update proof 8))

so:

one would still create two trunks (thus allowing for two registers and two global variables). unfortunately i do not have time right now to investigate a method to allow the global variables to be multiline so the IPt and COUNTt and NoOfChannels could be declared within that area. So that investigation will have to be completed (or just edit the .conf file, but that's just until we find out how to get multiline global variables with the GUI).

on each trunk:

register => has a line, and you must actually include the "register => " as part of the line.

[Trunk1] the entire sip context for each would be stored as usual (beginning with [Trunk1] to segregate them as usual)

[general] these variables would be moved to the "Global Variables" for each trunk (Trunk1=SIP/Trunk1 would go in Trunk1, for instance). Later we'll work out multiple variables

[default] this would be put in the dialplan entry and should NOT be _XXX but rather _91NXXNXXXXXX or an appropriate pattern for the area you are dialing (the 9 is used to bring the call to THIS plan and will then be discarded by changing {EXTEN} to {EXTEN:1} or {EXTEN:2} depending on the number of digits being discarded). This allows for multiple dialplans to reside on one box without interference.

excellent post 8)
Vicidial Installation and Repair, plus Hosting and Colocation
Newest Product: Vicidial Agent Only Beep - Beta
http://www.PoundTeam.com # 352-269-0000 # +44(203) 769-2294
williamconley
 
Posts: 20346
Joined: Wed Oct 31, 2007 4:17 pm
Location: Davenport, FL (By Disney!)

Postby joaosp » Thu May 26, 2011 8:07 am

Thank you for your reply.

Meanwhile, I found another way of doing the same thing, but this time with the added plus of being able to find if the trunk is already being used or not, so it won't get dialed again.

Here goes:

You need to use the GROUP capability to limit each trunk to a certain number of calls each and have failover to the next.

[macro-call-trunk]
exten => s,1,GotoIf($[${GROUP_COUNT(${ARG1})}=0]?avail:busy)
exten => s,n(avail),Set(GROUP()=${ARG1})
exten => s,n,Dial(${ARG2}||t)
exten => s,n,Hangup
exten => s,n(busy),Noop()

exten => _1NXXNXXXXXX,1,Macro(call-trunk|trunk-1|SIP/${EXTEN}@trunk1)
exten => _1NXXNXXXXXX,n,Macro(call-trunk|trunk-2|SIP/${EXTEN}@trunk2)
exten => _1NXXNXXXXXX,n,Macro(call-trunk|trunk-3|SIP/${EXTEN}@trunk3)

This is just really quickly done...

Basically the macro checks to see if the group count for the trunk is 0, if it is then the current call is set to use the group (which means the next time group_count gets called while this call is up, it'll return 1) and the destination is dialed. Otherwise it gets returned to the dialplan and it tries the next trunk.

There may be other solutions out there but you could expand on this one so that a trunk could support, for example, 2 outbound calls at a time. You would just see if the group_count is equal to 2 and if so jump to busy, otherwise avail.


Hope it helps who needs!
joaosp
 
Posts: 5
Joined: Mon Mar 28, 2011 7:19 am

Postby mflorell » Thu May 26, 2011 8:10 am

How are you initiating this call to the macro?

Are you running call_log on these calls?

How does using this affect load on your dialer?
mflorell
Site Admin
 
Posts: 18399
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Postby joaosp » Thu May 26, 2011 9:11 am

Got it to work on a testing server with 3 trunks but haven't got the time to watch logs/stats.

Will test it this weekend on a 25 sip trunk setup thats working with the 1st method i posted, after that ill post stats.

Meanwhile my server stats for the 1st setup are (with 25 trunks - 20 users):

Model Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz (8 core)
8gb RAM

Load Averages
0.19 0.19 0.18
2.51%
joaosp
 
Posts: 5
Joined: Mon Mar 28, 2011 7:19 am

Postby chasejordan1 » Thu May 26, 2011 12:06 pm

exten => _9X.,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _9X.,2,NoOp(LB IS ${lb_trunk})
exten => _9X.,3,GotoIf($[${lb_trunk} != 0]?10)
exten => _9X.,4,Set(GLOBAL(lb_trunk)=1)
exten => _9X.,5,Dial(${trunk_1}/${EXTEN:1},,tTor)

exten => _9X.,10,GotoIf($[${lb_trunk} != 1]?20)
exten => _9X.,11,Set(GLOBAL(lb_trunk)=2)
exten => _9X.,12,Dial(${trunk_2}/${EXTEN:1},,tTor)

exten => _9X.,20,GotoIf($[${lb_trunk} != 2]?30)
exten => _9X.,21,Set(GLOBAL(lb_trunk)=3)
exten => _9X.,22,Dial(${trunk_3}/${EXTEN:1},,tTor)

exten => _9X.,30,Set(GLOBAL(lb_trunk)=0)
exten => _9X.,31,Goto(1)


This works great, and you can add as many trunks as you like.
chasejordan1
 
Posts: 182
Joined: Fri Mar 07, 2008 11:57 am

Postby mflorell » Thu May 26, 2011 1:00 pm

That's pretty neat, thanks for posting!
mflorell
Site Admin
 
Posts: 18399
Joined: Wed Jun 07, 2006 2:45 pm
Location: Florida

Postby kashutu » Thu Jul 21, 2011 8:21 am

Guys this is a great post. Thank You.

I am in the same situation and was looking for this for a while.

Here is the scenario that i am into, i have 5 SIP Trunks with 2 channels each. I have 10 agents sitting on Goautodial. Right now i have setup 5 campaigns with 2 users each. I am looking to get Round Robin set up on my Goautodial server, here are the specs

Goautodial CE 2.0
VERSION: 2.2.1-237
BUILD: 100510-2015
Pentium 4 2.8 GHz 512 RAM

How can i setup it up on a single campaign through GUI? I would appreciate all your help.
If you need any further details, please do let me know.

Thank You
kashutu
 
Posts: 63
Joined: Thu Apr 14, 2011 6:18 am

Postby kashutu » Fri Jul 22, 2011 7:18 am

Hi,

Joaosp---> Before i tried your method, i had 5 SIP trunks working without any issues separatley. But since i have changed it to the method that you mentioned, the following happens in CLI>

console dial 918609464041@default
[Jul 22 17:03:16] == Console is full duplex
[Jul 22 17:03:16] -- Executing [918609464041@default:1] AGI("Console/dsp", "agi://127.0.0.1:4577/call_log") in new stack
[Jul 22 17:03:16] -- AGI Script agi://127.0.0.1:4577/call_log completed, returning 0
[Jul 22 17:03:16] -- Executing [918609464041@default:2] GotoIf("Console/dsp", "0?3:4") in new stack
[Jul 22 17:03:16] -- Goto (default,918609464041,4)
[Jul 22 17:03:16] -- Executing [918609464041@default:4] SetGlobalVar("Console/dsp", "COUNTt=3") in new stack
[Jul 22 17:03:16] == Setting global variable 'COUNTt' to '3'
[Jul 22 17:03:16] -- Executing [918609464041@default:5] SetGlobalVar("Console/dsp", "tr=") in new stack
[Jul 22 17:03:16] == Setting global variable 'tr' to ''
[Jul 22 17:03:16] -- Executing [918609464041@default:6] Dial("Console/dsp", "SIP/18609464041@|15|o") in new stack
[Jul 22 17:03:16] WARNING[4580]: chan_sip.c:3095 create_addr: No such host:
[Jul 22 17:03:16] WARNING[4580]: app_dial.c:1296 dial_exec_full: Unable to create channel of type 'SIP' (cause 20 - Unknown)
[Jul 22 17:03:16] == Everyone is busy/congested at this time (1:0/0/1)
[Jul 22 17:03:16] -- Executing [918609464041@default:7] Hangup("Console/dsp", "") in new stack
[Jul 22 17:03:16] == Spawn extension (default, 918609464041, 7) exited non-zero on 'Console/dsp'
[Jul 22 17:03:16] -- Executing [h@default:1] DeadAGI("Console/dsp", "agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----20-----CHANUNAVAIL----------") in new stack
[Jul 22 17:03:16] -- AGI Script agi://127.0.0.1:4577/call_log--HVcauses ... ---------- completed, returning 0
[Jul 22 17:03:16] << Hangup on console >>


Here is the configuration that i have put in for the carrier:

Registration String:

register=>xxxxx:xxxxxx@208.73.146.95:5060/xxxxxx


Account Entry:
[ibrain01]
disallow=all
allow=ulaw
username=xxxxxx
fromuser=xxxxxx
type=friend
secret=xxxxxx
qualify=no
maxexpirey=3600
host=208.73.146.95
fromdomain=208.73.146.95
insecure=invite
dtmfmode=rfc2833
defaultexpirey=60
nat=yes
canreinvite=no
context=trunkinbound


Global String:

VOIPTRUNK1=SIP/ibrain01


Dial Plan Entry:
exten => _91XXXXXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _91XXXXXXXXXX,2,Gotoif($["${COUNTt}" = "${NoOfChannels}"]?3:4)
exten => _91XXXXXXXXXX,3,SetGlobalVar(COUNTt=0])
exten => _91XXXXXXXXXX,4,SetGlobalVar(COUNTt=$[${COUNTt}+1])
exten => _91XXXXXXXXXX,5,SetGlobalVar(tr=${CUT(IPt,-,${COUNTt})})
exten => _91XXXXXXXXXX,6,Dial(SIP/${EXTEN:1}@${tr},15,o)
exten => _91XXXXXXXXXX,7,Hangup



Please help me out with this issue.
THank You
kashutu
 
Posts: 63
Joined: Thu Apr 14, 2011 6:18 am

Postby joaosp » Thu Jul 28, 2011 4:02 pm

Hello.

I think this is cause because the trunks are full (maxcalls) and when it tries to dial the next number on a full trunk it returns CONGESTION.

Im trying to fix this myself, since i have the same problem, but i can't really figure out how.

Any1 who could help would be appreciated!
joaosp
 
Posts: 5
Joined: Mon Mar 28, 2011 7:19 am

Postby mudasir » Tue Aug 02, 2011 4:53 pm

Hi everyone

Just wanted to add one thing. I am using the same method at two different sites.

On one site its working fine with 3 trunks.
One second site it gives the same error "CHANUNAVAIL".

When this error comes, I noticed that the value of variable COUNTt shown on console is much higher then the max number of channels (I have seen COUNTt=89 with 3 trunks).

And when I do "reload" and "dialplan reload" it starts to work again, because the value of variable becomes 0 again.

With separate trunks I am able to dial 100 numbers on each trunk, but when used with load balancing it starts giving errors only after 50 or 60 calls ringing.

As you can see in the example of kashutu, he is using only 1 trunk but getting COUNTt=3.
Kind Regards
Mudasir Mirza
mudasir
 
Posts: 77
Joined: Sat Jun 19, 2010 11:58 pm
Location: karachi, Pakistan

Postby williamconley » Tue Aug 02, 2011 6:28 pm

For curiosity, have you looked at this one?

http://www.vicidial.org/VICIDIALforum/v ... 3365#73365
Vicidial Installation and Repair, plus Hosting and Colocation
Newest Product: Vicidial Agent Only Beep - Beta
http://www.PoundTeam.com # 352-269-0000 # +44(203) 769-2294
williamconley
 
Posts: 20346
Joined: Wed Oct 31, 2007 4:17 pm
Location: Davenport, FL (By Disney!)

Postby mcargile » Tue Sep 13, 2011 3:27 pm

This is really neat. The only thing as Matt said is the logging. Your Macro HAS to have the h extension. Without it any call that hangs up during this macro for whatever reason will not get logged correctly and get stuck.
Michael Cargile | Director of Engineering | ViciDialGroup | http://www.vicidial.com

The official source for VICIDIAL services and support. 1-888-894-VICI (8424)
mcargile
Site Admin
 
Posts: 617
Joined: Tue Jan 16, 2007 9:38 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 21 guests