Author Topic: Round Robin in regexroute.conf  (Read 10045 times)

bnaetsch

  • Newbie
  • *
  • Posts: 9
    • View Profile
Round Robin in regexroute.conf
« on: January 07, 2016, 05:13:12 AM »
Hello

I dont understand why this
^.*$=fork $(index,$idx00,|sip/sip:\0@62.XXX.XX.XX0:5065,|sip/sip:\0@213.XX.XX.XX0:5065)
not works

It should distribute all incomming calls to more than one telephonie systems

I followed your example in the documentation
http://docs.yate.ro/wiki/Round_Robin_Routing

If I dont use round robin, like this
.*$=sip/sip:\0@62.XXX.XX.XX0:5065
it works fine

Here the Log
20160107114728.768263 <sip/2:ALL> YateSIPConnection::YateSIPConnection(0x6e69800658f0,0x6e6980065090) [0x6e6980065d40]
20160107114728.768731 <sip/2:ALL> NAT address is '(null)' [0x6e6980065d40]
20160107114728.769961 <sip/2:ALL> Set media: audio=alaw,mulaw [0x6e6980065d40]
20160107114728.771294 <INFO> Classifying caller '+493512XXXXX' in context 'inbound' in 273 usec
20160107114728.771470 <cdrbuild:INFO> Got message 'call.route' for untracked id 'sip/2'
20160107114728.772071 <INFO> Routing call to '+493518XXXXXX' in context 'inbound' via 'fork |sip/sip:+493518XXXXXX@213.XX.XX.XX0:5065' in 355 usec
20160107114728.772146 <sip/2:ALL> NAT address is '(null)' [0x6e6980065d40]
20160107114728.772928 <callfork:MILD> Call 'sip/2' ignoring modifier 'sip/sip:+493518XXXXXX@213.XX.XX.XX0:5065'
20160107114728.772989 <sip/2:ALL> YateSIPConnection::disconnected() '(null)' [0x6e6980065d40]
20160107114728.773215 <sip/2:MILD> Call rejected error='(null)' reason='(null)' [0x6e6980065d40]
20160107114728.775265 <sip/2:ALL> YateSIPConnection::hangup() state=0 trans=0x6e6980065090 error='failure' code=500 reason='(null)' [0x6e6980065d40]
20160107114728.775379 <sip/2:ALL> YateSIPConnection::~YateSIPConnection() [0x6e6980065d40]
20160107114728.775687 <sip:INFO> 'udp:0.0.0.0:5060' sending code 500 0x3927af0 to 85.XXX.XXX.206:5060 [0x390ddb0]

or

20160107111057.003374 <sip/1:ALL> YateSIPConnection::YateSIPConnection(0x6e6980058090,0x6e6980059f90) [0x6e698005a480]
20160107111057.003981 <sip/1:ALL> NAT address is '(null)' [0x6e698005a480]
20160107111057.005136 <sip/1:ALL> Set media: audio=alaw,mulaw [0x6e698005a480]
20160107111057.006194 <INFO> Classifying caller '+493512XXXXX' in context 'inbound' in 236 usec
20160107111057.006602 <cdrbuild:INFO> Got message 'call.route' for untracked id 'sip/1'
20160107111057.007068 <INFO> Routing call to '+493518XXXXXX' in context 'inbound' via 'fork |sip/sip:+493518XXXXXX@62.XXX.XX.XX0:5065' in 340 usec
20160107111057.007241 <sip/1:ALL> NAT address is '(null)' [0x6e698005a480]
20160107111057.008891 <callfork:MILD> Call 'sip/1' ignoring modifier 'sip/sip:+493518XXXXXX@62.XXX.XX.XX0:5065'
20160107111057.008921 <sip/1:ALL> YateSIPConnection::disconnected() '(null)' [0x6e698005a480]
20160107111057.009072 <sip/1:MILD> Call rejected error='(null)' reason='(null)' [0x6e698005a480]
20160107111057.009426 <sip/1:ALL> YateSIPConnection::hangup() state=0 trans=0x6e6980059f90 error='failure' code=500 reason='(null)' [0x6e698005a480]
20160107111057.009464 <sip/1:ALL> YateSIPConnection::~YateSIPConnection() [0x6e698005a480]
20160107111057.010929 <sip:INFO> 'udp:0.0.0.0:5060' sending code 500 0x3925ba0 to 85.131.161.206:5060 [0x390ddb0]

Thank you for your advice
Regards
Burkhard

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #1 on: January 08, 2016, 01:44:27 AM »
The pipe character '|' is a target by itself.
In your case you should either insert a space between | and next target or remove the pipe character: you have only one target.

More that that:
Since you have only one target you don't need the fork module, just route the call to sip:
^.*$=sip/sip:\0@$(index,$idx00,62.XXX.XX.XX0:5065,213.XX.XX.XX0:5065)

bnaetsch

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #2 on: January 08, 2016, 02:22:45 AM »
Thanks for your advice

it works fine

Regards
Burkhard

ky4k0b

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #3 on: August 07, 2019, 10:50:31 AM »
marian,

how can I round-robin between lines configured in accfile?
for instance I have two lines :
Code: [Select]
[123]
enabled=yes
protocol=sip
username=123
password=123
registrar=sip.registrar.com:5260

[456]
enabled=yes
protocol=sip
username=456
password=456
registrar=sip.registrar.com:5260

will this line in regexroute work? I mean if I have incoming call to dnis 123 will it be routed to line 123 and dnis 456 to according line 456?
Code: [Select]
^\(.*\)$=line/\1;line=\1

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #4 on: August 07, 2019, 11:59:54 PM »
If you want to route called number to its line: yes

ky4k0b

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #5 on: August 08, 2019, 03:37:07 AM »
marian,

but how can I do round-robin between these two lines?
Like this:
^.*$=sip/sip:\0@$(index,$idx00,62.XXX.XX.XX0:5065,213.XX.XX.XX0:5065)
but for registered lines
« Last Edit: August 08, 2019, 04:15:37 AM by ky4k0b »

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #6 on: August 08, 2019, 04:16:37 AM »
If you want to round robin lines no matter the called number:

[$once]
line=0

[default]
^.*$=line/\0;line=$(index,$line,123,456)

If not, please post a description of what exactly do you want to do.

ky4k0b

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #7 on: August 08, 2019, 04:58:03 AM »
yes, thats what I need.

can you explain what does it mean?

[$once]
line=0

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #8 on: August 08, 2019, 05:06:48 AM »
Initialize variable.

You may take a look at regexroute.conf for any information related to sections, functions ...

ky4k0b

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #9 on: August 08, 2019, 10:25:30 AM »
Line id is basically source number. Can I change caller-id on outgoing leg to selected line id?
Something like that:
^.*$=line/\0;line=$(index,$line,123,456);callername=$line

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #10 on: August 08, 2019, 11:45:01 PM »
^.*$=line/\0;line=$(index,$line,123,456);callername=${line}

ky4k0b

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #11 on: August 20, 2019, 08:53:12 AM »
marian,

as I can see from regexroute I can split called number with regexp and use parts further after "="
But how can I split caller number the same way? I have in incoming INVITE:
Contact: <sip:295987456223@1.2.3.4:5060>
I need to route it like this:
^38\(.*\)$=line/\1;line=23
where 23 is the last 2 digits from caller number

ky4k0b

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #12 on: August 20, 2019, 09:07:36 AM »
as far as I understand building routing rules I have to do the following

[$once]
ani=0

[default]
.*=call borsch

[borsch]
${caller}^.*\(..\)$=;ani=\1
^38\(.*\)$=line/\1;line=${ani}

or maybe I can do it with "match" but I didn't find any examples how to use it :(

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Round Robin in regexroute.conf
« Reply #13 on: August 26, 2019, 12:40:08 AM »
Here is an example of matching last 2 digits:

${caller}\([0-9]\{2\}\)$=;any=\1