[SR-Users] Multiple parallel branches, one invalid
Anthony Joseph Messina
amessina at messinet.com
Fri Mar 10 15:06:29 CET 2017
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
> 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.
# Save the original extension
# Only route a single branch via SIPOUT
# Save the return code from the lookup_branches function
# Asterisk failover route (for non-multibranch INVITEs)
# Route to VoiceMail (Leave VoiceMail)
send_reply("404", "Not Found");
send_reply("405", "Method Not Allowed");
... other stuff ...
... eventually: t_relay();
Anthony - https://messinet.com/ - https://messinet.com/~amessina/gallery
F9B6 560E 68EA 037D 8C3D D1C9 FF31 3BDB D9D8 99B6
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: This is a digitally signed message part.
More information about the sr-users