Hi Juha
Thanks so much for the response.
The method I posted was a slightly modified version of the method already posted in this thread.
What I believe the script is meant to do is as follows:
1) load gateways as per usual:
if (!load_gws(1, $rU, $fu)) {
sl_send_reply("502", "Unable to load gateways");
exit;}
2) Rewrite the current request uri to the first gateway or return an error if no gateways were found
if(!next_gw()){
sl_send_reply("503", "Unable To find a gateway");
exit;}
3) Add all the other gateways that were found as additional end points to be tried after the first
while(next_gw()){
append_branch(); }
The reason that I thought it might reverse the order of the gateways was because of something you said previously in the thread in response to the original poster:
" smaller priority value means higher priority. but if i remember correctly, in your script you used append_branch, which may be appending each new branch in front of the previous one. if so, the priority order that next_gw() function returns the gateways, get reversed. "
No one responded to your last post in the thread so I wasn't sure if it was determined if this method would reverse the order or not.
Thinking over this script a bit more I believe it is flawed or at the very least an incomplete example. It would cause all the branches to be contacted at once instead of in sequence. What really seems like it's needed here is something like the serial forking example found here: http://kamailio.org/docs/modules/3.1.x/modules/tm.html#tm.serial_forking
I went with trying the above method of doing the route advance because it was the only method my google search turned up.
Perhaps something very simple like a failure route that calls next_gw would do the trick instead:
failure_route["lcr_failure"] { if (!next_gw()) { t_reply("503", "Service not available - No more gateways"); exit; }; t_relay(); }
What I am trying to accomplish is having kamailio contact my next lcr gateways in sequence if the first attempt failed. Do either of these methods: either serial forking of branches generated in a while loop with next_gw or calling next_gw() in a failure route, seem like the right way to proceed?
Thanks again for your assistance.
I hope this message finds you well.
All the best
Will Ferrer
jh wrote
willf1976 writes:
So I take it then that the method described in this thread will work for making fall back routes for lcr that will run in the order of their priority, instead of in reverse order as some folks were saying in the thread?
read what lcr readme tells about priority. if it does not work as described, file a bug report.
I also am planning on switching to using append_branch instead of km_append_branch -- I thought I would mention this in case there was some reason that km_append_branch is being used instead. So in the end my script would look something much like this:
if (is_method("INVITE"))
{ if (!load_gws(1, $rU, $fu)) { sl_send_reply("502", "Unable to load gateways"); exit;} if(!next_gw()){ sl_send_reply("503", "Unable To find a gateway"); exit;} while(next_gw()){ append_branch(); } sl_send_reply("302","Moved temporary"); exit; }
you should call append_branch() after next_gw(). also, the above calls next_gw() twice. at some point you should call t_relay() to send the message.
-- juha
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@.sip-router
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- View this message in context: http://sip-router.1086192.n5.nabble.com/Kamailio-Redirect-message-300-with-L... Sent from the Users mailing list archive at Nabble.com.