Sasmita, I can’t provide a working example as I don’t have a use case like this. However, this piece of script you’ve provided does not represent a correct flow. I think you may need to review how the different types of routes, and particularly branch routes, work. [1]
I don’t have any experience with Registrar module, so take all of the following with a grain of salt. Someone with more experience with registrar can maybe keep me honest here. You should only need to call next_branches() one time, as it already loads all contacts returned by lookup() into parallel branches (assuming you are using the “b” flag for lookup()). This means they are all sent out at once, not serially. So you don’t need to send the next branch in failure_route because they’ve all already been sent. The branch route is executed as the last route before the message is being sent out. You certainly do not need to call next_branches() there either, in fact its behavior in a branch route is not defined in the docs. Also, I don’t know what your route “1” does, but you likely don’t need it from branch route either. As long as you don’t drop the branch, it will automatically be sent out. Lastly, you have the actual drop() command commented out, so this code won’t work as I described. Lastly, failure_route is armed for the whole request. In the case of parallel branching, it will only be called once for the request, not once for each branch, and only if all branches receive negative replies. One thing I’m not clear about is what happens if you end up dropping all the branches. I don’t know if failure_route would be called then, but it would be pretty easy to verify that. I think it would. Again, I can’t speak to your specific use case, but a representative version of the solution I recommended is below. *I have not tested or verified this code.* route { # all of your normal routing logic if (lookup(“<domain>”, “b”)) { if (next_branches()) { t_on_branch(“check_attrs”); t_on_failure(“no_branches”); } else { # handle case of no contacts t_reply(404, “Not Found”); } } else { # handle case of failed lookup t_reply(404, “Not Found”); } } branch_route[check_attrs] { $var(count) = $(hdr(Call-Info){csv.count}); while($(var(count) >= 0)) { if ($(avp(attr){s.index, $(hdr(Call-Info){csv.value,$var(i)})}) == NULL) { # as soon as one requirement doesn’t match, you know you don’t want to route drop(); } xlog("count: $var(count)\n"); $var(count) = $var(count) - 1; } } failure_route[no_branches] { # handle case where all branches failed t_reply(404, “Not Found”); } [1] https://www.opensips.org/Documentation/Script-Routes-3-2 Ben Newlin From: Users <users-boun...@lists.opensips.org> on behalf of Sasmita Panda <spa...@3clogic.com> Date: Thursday, November 2, 2023 at 9:36 AM To: OpenSIPS users mailling list <users@lists.opensips.org> Subject: Re: [OpenSIPS-Users] I need some help in attr matching while forming the Branch . ________________________________ Hi Ben , failure_route[1] { if ( t_check_status("404|477|480|481|408|486|50[234]")){ if (next_branches()) { t_on_branch("attr"); } } } branch_route[attr] { $var(count) = $(hdr(Call-Info){csv.count}); $var(i) = 0; $var(match-count) = 0; while($var(i) < $(var(count))){ if ($(avp(attr){s.index, $(hdr(Call-Info){csv.value,$var(i)})}) != NULL){ xlog("counter: $var(i)th index matched in attribute \n"); $var(match-count)= $var(match-count) + 1; } xlog("counter: $var(i)\n"); $var(i) = $var(i) + 1; } if ($var(i) == $var(match-count)){ ## Here I want to give call to that contact .. if that fails then again it should come to next branch and again compare t_on_failure("1"); route(1); } else{ # Here if the condition does not match . then i want to do the comparison again if (next_branches()){ t_on_branch("attr"); } # drop(); } } As for my expectation, it's not working . How does it work ? Where should I use T_branch_Idx ? Can I get some examples of this ? Thanks & Regards Sasmita Panda Senior Network Testing and Software Engineer 3CLogic , ph:07827611765
_______________________________________________ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users