Hey everyone, Just wanted to bounce some things off the list to make sure I'm not heading down the wrong path here. I'll quickly explain my problem and then explain my plan to deal with it. Please let me know if anyone sees an issue here.
Problem: I need to send FROM two different IP addresses based on the LCR group returned from next_gw();. For example, if the gateway returned is in group_id=1 from the LCR I need to send FROM 1.1.1.1:5060, if it's from group_id=2, I need to send FROM 1.1.1.2:5060. I need to do this on REQUEST_ROUTE and FAILURE_ROUTE. Here is what I am thinking will work:
modparam("pv","shvset","gw_one=s:1.1.1.1:5060") modparam("pv","shvset","gw_two=s:1.1.1.2:5060")
route{
load_gws(); next_gw();
if(to_gw("1")){ force_send_socket($shv(gw_one)); }else if(to_gw("2")){ force_send_socket($shv(gw_two)); }
}
Sorry for not just trying this out on my own. I currently don't have access to a dev machine, and I need to make changes to the live script... so I would prefer not to have a ton of restarts while trying to work the bugs out.
Thanks.
Geoffrey Mina writes:
modparam("pv","shvset","gw_one=s:1.1.1.1:5060") modparam("pv","shvset","gw_two=s:1.1.1.2:5060")
route{
load_gws(); next_gw();
if(to_gw("1")){ force_send_socket($shv(gw_one)); }else if(to_gw("2")){ force_send_socket($shv(gw_two)); }
}
force_send_socket does what do want to do, but i don't know if it accepts pv argument. also, i don't see why you need to use pv argument, rather than write force_send_socket(1.1.1.1:5060), etc.
-- juha
OK, but since this is 1.5, I would still use the GW Group ID, correct?
On Fri, Jun 25, 2010 at 4:14 PM, Juha Heinanen jh@tutpro.com wrote:
Juha Heinanen writes:
if(to_gw("1")){ force_send_socket($shv(gw_one)); }else if(to_gw("2")){ force_send_socket($shv(gw_two)); }
also, in 3.0 and later, to_gw takes lcr_id as argument, not gw group.
-- juha
The only reason I would choose to keep the values at the top is because I have 4 machines which all need a copy of the script.... but would need the IP changed per machine. Since the IP will be referenced in both REQUEST_ROUTE and FAILURE_ROUTE, i just figured it was easier to store in a PV instead of having to change it 2 places for each machine.
Thanks.
On Fri, Jun 25, 2010 at 4:12 PM, Juha Heinanen jh@tutpro.com wrote:
Geoffrey Mina writes:
modparam("pv","shvset","gw_one=s:1.1.1.1:5060") modparam("pv","shvset","gw_two=s:1.1.1.2:5060")
route{
load_gws(); next_gw();
if(to_gw("1")){ force_send_socket($shv(gw_one)); }else if(to_gw("2")){ force_send_socket($shv(gw_two)); }
}
force_send_socket does what do want to do, but i don't know if it accepts pv argument. also, i don't see why you need to use pv argument, rather than write force_send_socket(1.1.1.1:5060), etc.
-- juha
OK, I am running into some errors when starting my script:
if(to_gw("1")){ force_send_socket(X.X.X.180:5060); }else if(to_gw("3")){ force_send_socket(X.X.X.179:5060); }else if(to_gw("4")){ force_send_socket(X.X.X.189:5060); }
Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:pv_parse_spec: bad parameters Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:fixup_pvar: parsing of pseudo variable 1 failed! Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:fix_actions: fixing failed (code=-1) at cfg line 348 Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: CRITICAL:core:fix_expr: fix_actions error Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:main: failed to fix configuration with err code -1
Perhaps I an confused about how the to_gw() function of the LCR module is to be used. In my "gw" table, I have gateways with grp_id 1, 3, and 4. I am assuming that is the value I should be checking for in the to_gw() function, but it seems to be expecting a pseudo variable or something.
What am I missing?
Thanks!
On Fri, Jun 25, 2010 at 4:31 PM, Geoffrey Mina geoffreymina@gmail.comwrote:
The only reason I would choose to keep the values at the top is because I have 4 machines which all need a copy of the script.... but would need the IP changed per machine. Since the IP will be referenced in both REQUEST_ROUTE and FAILURE_ROUTE, i just figured it was easier to store in a PV instead of having to change it 2 places for each machine.
Thanks.
On Fri, Jun 25, 2010 at 4:12 PM, Juha Heinanen jh@tutpro.com wrote:
Geoffrey Mina writes:
modparam("pv","shvset","gw_one=s:1.1.1.1:5060") modparam("pv","shvset","gw_two=s:1.1.1.2:5060")
route{
load_gws(); next_gw();
if(to_gw("1")){ force_send_socket($shv(gw_one)); }else if(to_gw("2")){ force_send_socket($shv(gw_two)); }
}
force_send_socket does what do want to do, but i don't know if it accepts pv argument. also, i don't see why you need to use pv argument, rather than write force_send_socket(1.1.1.1:5060), etc.
-- juha
2010/6/25 Geoffrey Mina geoffreymina@gmail.com:
OK, I am running into some errors when starting my script:
if(to_gw("1")){ force_send_socket(X.X.X.180:5060); }else if(to_gw("3")){ force_send_socket(X.X.X.179:5060); }else if(to_gw("4")){ force_send_socket(X.X.X.189:5060); }
Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:pv_parse_spec: bad parameters Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:fixup_pvar: parsing of pseudo variable 1 failed! Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:fix_actions: fixing failed (code=-1) at cfg line 348 Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: CRITICAL:core:fix_expr: fix_actions error Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:main: failed to fix configuration with err code -1
Perhaps I an confused about how the to_gw() function of the LCR module is to be used. In my "gw" table, I have gateways with grp_id 1, 3, and 4. I am assuming that is the value I should be checking for in the to_gw() function, but it seems to be expecting a pseudo variable or something.
Theorically (according to the LCR documentation), "to_gw()" must be used when processing in-dialog requests. However I'm not sure of the cause of your error, which is exactly the line 384 in your script?
Anyhow I suggest you a different approach:
- Set a different flag for each gw (in LCR 'gw' table) depending on the sending socket that must be used. - After calling 'next_gw()' inspect the value of the gw flags (stored in a configured AVP) and choose which 'force_send_socket()' to use.
OK, couple more questions regarding my two options. So far I can potentially use to_gw_grp("1") OR I can use the flags AVP to store a flag which dictates what my send_socket will be. Here are my challenges with each:
1 - to_gw_grp("1"). How would I ensure that subsequent in-dialog requests are sent from the same socket as the original INVITE to my ITSP.
Asterisk --> INVITE --> KAMAILIO --> (next_gw()/to_gw_grp("1")/force_send_socket() --> INVITE --> ITSP Asterisk --> BYE --> KAMAILIO --> (if(loose_route(){t_relay();}) -- BYE --> ITSP
How would I call the to_gw_grp("1") in this scenario? Would I just call it after calling loose_route(), but before calling t_relay()?
2 - using AVP flags. The AVP is only set after the initial call to next_gw(), how would I have access to this flag for in-dialog requests? I could perhaps store it in a htable with call-id as the key and overwrite the value each time we call next_gw() (in the event there are failures)... just not sure this is the best idea.
Thanks to everyone for your time and effort here.
Much appreciated!
-Geoff
On Fri, Jun 25, 2010 at 7:45 PM, Iñaki Baz Castillo ibc@aliax.net wrote:
2010/6/25 Geoffrey Mina geoffreymina@gmail.com:
OK, I am running into some errors when starting my script:
if(to_gw("1")){ force_send_socket(X.X.X.180:5060); }else if(to_gw("3")){ force_send_socket(X.X.X.179:5060); }else if(to_gw("4")){ force_send_socket(X.X.X.189:5060); }
Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:pv_parse_spec: bad parameters Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:fixup_pvar: parsing of pseudo variable 1 failed! Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:fix_actions: fixing failed (code=-1) at cfg line 348 Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: CRITICAL:core:fix_expr: fix_actions error Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:main: failed to fix configuration with err code -1
Perhaps I an confused about how the to_gw() function of the LCR module is
to
be used. In my "gw" table, I have gateways with grp_id 1, 3, and 4. I
am
assuming that is the value I should be checking for in the to_gw()
function,
but it seems to be expecting a pseudo variable or something.
Theorically (according to the LCR documentation), "to_gw()" must be used when processing in-dialog requests. However I'm not sure of the cause of your error, which is exactly the line 384 in your script?
Anyhow I suggest you a different approach:
- Set a different flag for each gw (in LCR 'gw' table) depending on
the sending socket that must be used.
- After calling 'next_gw()' inspect the value of the gw flags (stored
in a configured AVP) and choose which 'force_send_socket()' to use.
-- Iñaki Baz Castillo ibc@aliax.net
2010/6/27 Geoffrey Mina geoffreymina@gmail.com:
Asterisk --> INVITE --> KAMAILIO --> (next_gw()/to_gw_grp("1")/force_send_socket() --> INVITE --> ITSP Asterisk --> BYE --> KAMAILIO --> (if(loose_route(){t_relay();}) -- BYE --> ITSP
How would I call the to_gw_grp("1") in this scenario? Would I just call it after calling loose_route(), but before calling t_relay()?
Yes, why not? an in-dialog request (as BYE) has a RURI pointing to the server address (the Contact URI of the 200 OK fot the initial INVITE).
Geoffrey Mina writes:
1 - to_gw_grp("1"). How would I ensure that subsequent in-dialog requests are sent from the same socket as the original INVITE to my ITSP.
Asterisk --> INVITE --> KAMAILIO --> (next_gw()/to_gw_grp("1")/force_send_socket() --> INVITE --> ITSP Asterisk --> BYE --> KAMAILIO --> (if(loose_route(){t_relay();}) -- BYE --> ITSP
How would I call the to_gw_grp("1") in this scenario? Would I just call it after calling loose_route(), but before calling t_relay()?
yes (i think inaki already replied to this). another possibility might be to store the socket info in r-r header of initial request.
-- juha
Hello
I use same scenario as Geoffrey. But I have problem with force_send_socket() in failure_route[1]. If is first gw online, then everything is ok, force send socket work. But when first gw is offline and lcr try second gw, then message go trough socket which is called on first gw. I am using kamailio 1.4.2. Is this a bug?
Thank you
Ernest
On 27. 06. 2010 19:29, Juha Heinanen wrote:
Geoffrey Mina writes:
1 - to_gw_grp("1"). How would I ensure that subsequent in-dialog requests are sent from the same socket as the original INVITE to my ITSP.
Asterisk --> INVITE --> KAMAILIO --> (next_gw()/to_gw_grp("1")/force_send_socket() --> INVITE --> ITSP Asterisk --> BYE --> KAMAILIO --> (if(loose_route(){t_relay();}) -- BYE --> ITSP
How would I call the to_gw_grp("1") in this scenario? Would I just call it after calling loose_route(), but before calling t_relay()?
yes (i think inaki already replied to this). another possibility might be to store the socket info in r-r header of initial request.
-- juha
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Ernest Mavrel writes:
I use same scenario as Geoffrey. But I have problem with force_send_socket() in failure_route[1]. If is first gw online, then everything is ok, force send socket work. But when first gw is offline and lcr try second gw, then message go trough socket which is called on first gw. I am using kamailio 1.4.2. Is this a bug?
i don't know if it is a bug or not, but i call force_send_socket in branch route and it has worked as expected.
-- juha
2010/6/28 Juha Heinanen jh@tutpro.com:
Ernest Mavrel writes:
I use same scenario as Geoffrey. But I have problem with force_send_socket() in failure_route[1]. If is first gw online, then everything is ok, force send socket work. But when first gw is offline and lcr try second gw, then message go trough socket which is called on first gw. I am using kamailio 1.4.2. Is this a bug?
i don't know if it is a bug or not, but i call force_send_socket in branch route and it has worked as expected.
It's required to use to_gw_grp() in branch_route as changes done by LCR in the RURI are not visible until etering into branch_route.
OK, I have decided to use htable to store the AVP returned by the LCR module. I have everything working, except I have run into a strange issue with my failure_route logic.
Immediately after calling next_gw() in my initial REQUEST_ROUTE or FAILURE_ROUTE, I populate an htable which maps the socket I should send all in-dialog requests from. This gets reset each time we call next_gw() in the event that a gateway can't service my request for some reason. The issue I have is that on FAILURE_ROUTE scenarios where I am fetching the next gateway, it doesn't appear that the force_send_socket() is actually working for subsequent calls. The real example I am seeing is below. I am seeing my log in the ELSE statement, but Kamailio continues to send FROM X.X.X.180. Not sure what I could be doing wrong...
method status fromip toip send_grp INVITE udp:X.X.X.190:5060 udp:X.X.X.179:5060 INVITE udp:X.X.X.180:5060 udp:216.82.224.202:5060 1 INVITE 100 udp: 216.82.224.202:5060 udp:X.X.X.180:5060 INVITE 408 udp:216.82.224.202:5060 udp:X.X.X.180:5060 INVITE udp:X.X.X.180:5060 udp:216.82.225.202:5060 1 INVITE 100 udp: 216.82.225.202:5060 udp:X.X.X.180:5060 INVITE 404 udp:216.82.225.202:5060 udp:X.X.X.180:5060 INVITE udp:X.X.X.180:5060 udp:209.249.3.78:5060 0 INVITE 100 udp:209.249.3.78:5060 udp:X.X.X.180:5060 INVITE 503 udp:209.249.3.78:5060 udp:X.X.X.180:5060 INVITE udp:X.X.X.180:5060 udp:208.93.226.12:5060 0 INVITE 100 udp: 208.93.226.12:5060 udp:X.X.X.180:5060 INVITE 503 udp:208.93.226.12:5060 udp:X.X.X.180:5060 INVITE 503 udp:X.X.X.179:5060 udp:X.X.X.190:5060 ACK udp:X.X.X.190:5060 udp:X.X.X.179:5060
if(next_gw()){ $sht(send_grp=>$ci) = $avp(i:712);
if($sht(send_grp=>$ci) == 1){ xlog("L_INFO", "failure_route[1] - send_group==1; sending from .180 $ru"); force_send_socket(X.X.X.180:5060); }else if($sht(send_grp=>$ci) == 2){ xlog("L_INFO", "failure_route[1] - send_group==2; sending from .180 $ru"); force_send_socket(X.X.X.189:5060); }else{ xlog("L_INFO", "failure_route[1] - default send group; sending from .179 $ru"); force_send_socket(X.X.X.179:5060); }
t_on_reply("1"); t_on_failure("1"); t_relay(); }else{ # let the reply go upstram - it is the default action xlog("L_ERR", "No Next Gateway - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); exit; }
On Mon, Jun 28, 2010 at 4:41 AM, Iñaki Baz Castillo ibc@aliax.net wrote:
2010/6/28 Juha Heinanen jh@tutpro.com:
Ernest Mavrel writes:
I use same scenario as Geoffrey. But I have problem with force_send_socket() in failure_route[1]. If is first gw online, then everything is ok, force send socket work. But when first gw is offline and lcr try second gw, then message go trough socket which is called on first gw. I am using kamailio 1.4.2. Is this a bug?
i don't know if it is a bug or not, but i call force_send_socket in branch route and it has worked as expected.
It's required to use to_gw_grp() in branch_route as changes done by LCR in the RURI are not visible until etering into branch_route.
-- Iñaki Baz Castillo ibc@aliax.net
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Geoffrey Mina writes:
OK, I am running into some errors when starting my script:
if(to_gw("1")){ force_send_socket(X.X.X.180:5060); }else if(to_gw("3")){ force_send_socket(X.X.X.179:5060); }else if(to_gw("4")){ force_send_socket(X.X.X.189:5060); }
Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:pv_parse_spec: bad parameters
you need to call to_gw_grp("1").
-- juha
2010/6/26 Juha Heinanen jh@tutpro.com:
Geoffrey Mina writes:
OK, I am running into some errors when starting my script:
if(to_gw("1")){ force_send_socket(X.X.X.180:5060); }else if(to_gw("3")){ force_send_socket(X.X.X.179:5060); }else if(to_gw("4")){ force_send_socket(X.X.X.189:5060); }
Jun 25 16:45:14 atl-sipgateway1 /usr/local/sbin/kamailio[15942]: ERROR:core:pv_parse_spec: bad parameters
you need to call to_gw_grp("1").
That is not documented in 1.5:
http://kamailio.org/docs/modules/1.5.x/lcr.html#id2527249
In fact suh documentation states that to_gw("1") is the correct syntax. ¿?
you need to call to_gw_grp("1").
That is not documented in 1.5:
http://kamailio.org/docs/modules/1.5.x/lcr.html#id2527249
In fact suh documentation states that to_gw("1") is the correct syntax.
inaki,
thanks for the report. i just fixed the documentation.
-- juha