On Thursday, March 9, 2017 8:16:55 PM CST Nathan Ward wrote: > I have a scenario I’m not sure of the best way to solve. > > I use alias_db and have multiple destinations for a single number, and have > append_branches set to 1. I then use lookup_branches to get details from > the location table for each branch. I then do t_load_contacts and > t_next_contacts, then t_relay to parallel fork the calls to the > destination, and all the phones ring at once. > > This all works great if all the destinations from the dbaliases table are > online. > > However, if one of them is offline, lookup_branches says "Not found in > usrloc”. This branch is still there, and the call is attempted. In my > environment, this then does a DNS lookup, can’t resolve the domain, and the > branch fails. This is the first branch that is tried, and when this branch > has an error like this, it causes t_relay() to fail - I check for the > output of t_relay() and reply with an error - per the default config that > Kamailio ships with. > > I guess what I need to figure out, is if there’s a way to have t_relay fail > only if all branches fail? Or, is there a more elegant way to handle this? > > I should add, I only allow a single registration per subscriber - so, > lookup_branches only returns one branch per alias from alias_db_lookup.
I'm not sure if this will work for you, but I have a similar situation where I lookup_branches after alias_db_lookup. Just like you, if at least one of the branches is found by lookup_branches, then the call works ok. If none of the branches are found, then things don't work. If I understand you correctly, you need to check if lookup_branches fails (no branches are found) and handle the call differently before any call to t_relay. For me, I do a quick check of the branch count and decide what to do from there, i.e., multibranch calls get handled differently and in my case will route to voicemail using $avp(oexten) if none of the users are online. route[LOCATION] { # Save the original extension $avp(oexten)=$rU; #!ifdef WITH_ALIASDB if(alias_db_lookup("dbaliases")) { # Only route a single branch via SIPOUT if($branch(count)==0) { route(SIPOUT); } } #!endif if(!lookup_branches("location")) { # Save the return code from the lookup_branches function $var(rc_lookup_branches)=$rc; # Asterisk failover route (for non-multibranch INVITEs) if($branch(count)==0) { route(ASTERISK); } # Route to VoiceMail (Leave VoiceMail) route(VOICEMAIL); t_newtran(); switch($var(rc_lookup_branches)) { case -1: case -3: send_reply("404", "Not Found"); exit; case -2: send_reply("405", "Method Not Allowed"); exit; } } ... other stuff ... ... eventually: t_relay(); } -- Anthony - https://messinet.com/ - https://messinet.com/~amessina/gallery F9B6 560E 68EA 037D 8C3D D1C9 FF31 3BDB D9D8 99B6
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ 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