Hi,
I'm trying to use LCR with kamailio v5.5.4
gw, rule and rule_target are stored on mysql.
for lcr rules, do you know if prefix is mandatory ?
I first wanted to start using request_uri instead and leave the prefix column null/empty because prefix seems not to support regexp, I don't want to add the same rule with different prefixes.
but I'm facing issues
my database is fulfilled with :
lcr_gw
+----+--------+--------------+---------------+----------+------+--------+------------+-----------+-------+--------+-------------+-------+---------+
| id | lcr_id | gw_name | ip_addr | hostname | port | params | uri_scheme | transport | strip | prefix | tag | flags | defunct |
+----+--------+--------------+---------------+----------+------+--------+------------+-----------+-------+--------+-------------+-------+---------+
| 1 | 1 | carrier1 | 10.78.51.3 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | fd=carrier1 | 0 | NULL |
| 2 | 1 | carrier2 | 10.78.51.3 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | fd=carrier2 | 0 | NULL |
| 3 | 1 | carrier3 | 10.192.50.212 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 6 | 1 | carrier4 | 10.192.50.3 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | fd=carrier4 | 0 | NULL |
| 10 | 1 | carrier5 | 10.192.50.3 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | fd=carrier5 | 0 | NULL |
| 18 | 1 | carrier6 | 10.192.50.214 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 20 | 1 | carrier7 | 10.192.50.210 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 30 | 1 | carrier8 | 10.192.50.211 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 31 | 1 | carrier9 | 10.192.50.216 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 32 | 2 | media1 | 10.192.50.232 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 33 | 2 | media2 | 10.192.50.233 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 34 | 2 | media3 | 10.192.50.234 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 35 | 2 | media4 | 10.192.50.235 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 36 | 2 | media5 | 10.192.50.240 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 37 | 2 | media6 | 10.192.50.241 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 38 | 2 | media7 | 10.192.50.242 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | NULL | 0 | NULL |
| 39 | 3 | xivo-231 | 10.192.50.231 | NULL | 5060 | NULL | NULL | 1 | NULL | NULL | cps=5;cc=50 | 0 | NULL |
+----+--------+--------------+---------------+----------+------+--------+------------+-----------+-------+--------+-------------+-------+---------+
lcr_rule
+----+------------------------+-----------------------------------+------------------+--------+----------+-----------+---------+---------+
| id | desc | request_uri | lcr_id | prefix | from_uri | mt_tvalue | stopper | enabled |
+----+------------------------+-----------------------------------+------------------+--------+----------+-----------+---------+---------+
| 1 | Default | .+ | 1 | NULL | NULL | NULL | 0 | 1 |
| 2 | France GSM | (0|(|00|\+)33)[67]\d{8} | 1 | NULL | NULL | NULL | 1 | 1 |
| 3 | France | (0|(|00|\+)33)[1-59]\d{8} | 1 | NULL | NULL | NULL | 1 | 1 |
| 4 | International default | (00|\+)[1-9].+ | 1 | NULL | NULL | NULL | 1 | 1 |
| 5 | Italy | (00|\+)39.+ | 1 | NULL | NULL | NULL | 1 | 1 |
| 14 | to_oldmedias | .+ | 2 | NULL | NULL | NULL | 0 | 1 |
+----+------------------------+-----------------------------------+-------------------+--------+----------+-----------+---------+---------+
lcr_rule_target
+----+--------+---------+-------+----------+--------+
| id | lcr_id | rule_id | gw_id | priority | weight |
+----+--------+---------+-------+----------+--------+
| 25 | 1 | 3 | 3 | 1 | 1 |
| 26 | 1 | 3 | 18 | 2 | 1 |
| 28 | 1 | 3 | 30 | 3 | 1 |
| 29 | 1 | 2 | 30 | 4 | 1 |
| 30 | 1 | 2 | 3 | 2 | 1 |
| 31 | 1 | 2 | 18 | 3 | 1 |
| 32 | 1 | 2 | 20 | 1 | 1 |
| 33 | 1 | 1 | 30 | 1 | 1 |
| 34 | 1 | 12 | 1 | 1 | 1 |
| 35 | 1 | 12 | 10 | 1 | 1 |
| 37 | 2 | 14 | 32 | 1 | 1 |
| 38 | 2 | 14 | 33 | 1 | 1 |
| 39 | 2 | 14 | 34 | 1 | 1 |
| 40 | 2 | 14 | 35 | 1 | 1 |
| 41 | 2 | 14 | 36 | 1 | 1 |
| 42 | 2 | 14 | 37 | 1 | 1 |
| 43 | 2 | 14 | 38 | 1 | 1 |
| 45 | 1 | 2 | 10 | 3 | 1 |
+----+--------+---------+-------+----------+--------+
to test gws, I use kamcmd
for example :
kamcmd lcr.load_gws 1 s:0600000001 s:02111111111 s:0600000001
arg 1 : prefix or $rU
arg 2 : from_uri
arg 3 : request_uri
result is OK with 5 gateways selected
but in real test situation with the following config file :
kamailio.cfg :
request_route {
...
if(!load_gws(1,$rU,$fU)) {
sl_send_reply("500", "Cannot load gateways");
exit;
}
## - dumping the list of lcr gateways
$var(i) = 0;
while( $(avp(lcr_gw_uri)[$var(i)]) != $null) {
xlog("L_ERR","loaded gw_uri_avp[$var(i)]=’$(avp(lcr_gw_uri)[$var(i)])’\n");
$var(i) = $var(i) + 1;
}
if(!next_gw()) {
sl_send_reply("503", "No gateways found");
exit;
}
}
.....
=> we receive a 503 "No gateways found", which indicate that load_gws() is OK, but wasn't able to parse avp lcr_gw_uri (we have no xlog output)
Then I noticed that some calls are OK and others are KO (with same pattern for $rU) => lcr rule id 2
So I with debug=3
call to 0611111111 => load_gws OK and next_gw OK lcr [lcr_mod.c:3018]: do_from_gw(): request did not come from gw
lcr [lcr_mod.c:3018]: do_from_gw(): request did not come from gw
lcr [lcr_mod.c:3004]: do_from_gw(): request game from gw
lcr [lcr_mod.c:3009]: do_from_gw(): added tag_avp <cps=5;cc=50>
lcr [lcr_mod.c:2264]: ki_load_gws_furi(): load_gws(1, 0611111111, 0211111111)
lcr [lcr_mod.c:2313]: ki_load_gws_furi(): from uri <0211111111> did not match to from regex <AMD>
lcr [lcr_mod.c:2349]: ki_load_gws_furi(): request uri <
sip:0611111111@10.192.50.227:5060> did not match to request regex <(00|\+)39.+>
lcr [lcr_mod.c:2349]: ki_load_gws_furi(): request uri <
sip:0611111111@10.192.50.227:5060> did not match to request regex <(00|\+)[1-9].+>
lcr [lcr_mod.c:2349]: ki_load_gws_furi(): request uri <
sip:0611111111@10.192.50.227:5060> did not match to request regex <(0|(|00|\+)33)[1-59]\d{8}>
lcr [lcr_mod.c:2369]: ki_load_gws_furi(): added matched_gws[0]=[4, 0, 3, 2329862]
lcr [lcr_mod.c:2369]: ki_load_gws_furi(): added matched_gws[1]=[5, 0, 1, 5553909]
lcr [lcr_mod.c:2369]: ki_load_gws_furi(): added matched_gws[2]=[8, 0, 3, 7256660]
lcr [lcr_mod.c:2369]: ki_load_gws_furi(): added matched_gws[3]=[7, 0, 2, 3129551]
lcr [lcr_mod.c:2369]: ki_load_gws_furi(): added matched_gws[4]=[6, 0, 4, 2234577]
lcr [lcr_mod.c:2085]: add_gws_into_avps(): added gw_uri_avp <6|sip:|0|||3543318538||5060||;transport=udp|0|2> with weight <2234577>
lcr [lcr_mod.c:2085]: add_gws_into_avps(): added gw_uri_avp <4|sip:|0||fd=carrier5|53657610||5060||;transport=udp|0|2> with weight <2329862>
lcr [lcr_mod.c:2085]: add_gws_into_avps(): added gw_uri_avp <8|sip:|0|||3593650186||5060||;transport=udp|0|2> with weight <7256660>
lcr [lcr_mod.c:2085]: add_gws_into_avps(): added gw_uri_avp <7|sip:|0|||3560095754||5060||;transport=udp|0|2> with weight <3129551>
lcr [lcr_mod.c:2085]: add_gws_into_avps(): added gw_uri_avp <5|sip:|0|||3526541322||5060||;transport=udp|0|2> with weight <5553909>
lcr [lcr_mod.c:2610]: generate_uris(): r_uri <sip:0611111111@10.192.50.210:5060;transport=udp>, dst_uri <>
lcr [lcr_mod.c:2904]: ki_next_gw(): added ruri_user_avp <0611111111>
lcr [lcr_mod.c:2950]: ki_next_gw(): added tag_avp <>
lcr [lcr_mod.c:2965]: ki_next_gw(): added defunct_gw_avp <3526541322>
lcr [lcr_mod.c:2610]: generate_uris(): r_uri <sip:0611111111@10.192.50.212:5060;transport=udp>, dst_uri <>
lcr [lcr_mod.c:2950]: ki_next_gw(): added tag_avp <>
lcr [lcr_mod.c:2965]: ki_next_gw(): added defunct_gw_avp <3560095754>
lcr [lcr_mod.c:2610]: generate_uris(): r_uri <sip:0611111111@10.192.50.214:5060;transport=udp>, dst_uri <>
lcr [lcr_mod.c:2950]: ki_next_gw(): added tag_avp <>
lcr [lcr_mod.c:2965]: ki_next_gw(): added defunct_gw_avp <3593650186>
lcr [lcr_mod.c:2610]: generate_uris(): r_uri <sip:0611111111@10.192.50.3:5060;transport=udp>, dst_uri <>
lcr [lcr_mod.c:2950]: ki_next_gw(): added tag_avp <fd=carrier5>
lcr [lcr_mod.c:2965]: ki_next_gw(): added defunct_gw_avp <53657610>
lcr [lcr_mod.c:2610]: generate_uris(): r_uri <sip:0611111111@10.192.50.211:5060;transport=udp>, dst_uri <>
lcr [lcr_mod.c:2950]: ki_next_gw(): added tag_avp <>
lcr [lcr_mod.c:2965]: ki_next_gw(): added defunct_gw_avp <3543318538>
the right gws are selected and call are routed to them
call to 0600000001 => load_gws OK and next_gw KO lcr [lcr_mod.c:3018]: do_from_gw(): request did not come from gw
lcr [lcr_mod.c:3018]: do_from_gw(): request did not come from gw
lcr [lcr_mod.c:3004]: do_from_gw(): request game from gw
lcr [lcr_mod.c:3009]: do_from_gw(): added tag_avp <cps=5;cc=50>
lcr [lcr_mod.c:2264]: ki_load_gws_furi(): load_gws(1, 0600000001, 0211111111)
lcr [lcr_mod.c:2313]: ki_load_gws_furi(): from uri <0170619309> did not match to from regex <AMD>
the process stops after trying to match rule with regexp <(00|\+)39.+>
Don't know if it's a bug or if I misunderstood something !
Thanks in advance !
Best regards,