Hi, 

before using t_relay you can probably check if next hop uri is still in the target group with

ds_is_from_list([groupid [, mode [, uri] ] ])



for example ds_is_from_list("3","3","$du"); all parameters can be variables too.

you can check on documentation the mode parameter to see how comparison is done.




De : geoff.goas--- via sr-users <sr-users@lists.kamailio.org>
Envoyé : mardi 26 septembre 2023 21:02
À : sr-users@lists.kamailio.org <sr-users@lists.kamailio.org>
Cc : geoff.goas@interoptechnologies.com <geoff.goas@interoptechnologies.com>
Objet : [SR-Users] What is the expected behavior for dispatcher's ds_next_dst?
 
Hello,

I have some questions about dispatcher's behavior. I noticed that when I first ds_select_dst() a specific dispatcher group ID, ds_next_dst() will cycle through the active destinations in that group. When it reaches the end of the destinations in the group, it does not return "false", instead it starts to return destinations that are not a part of that group, ie. those destinations which are listed prior to the selected group in the dispatcher.list file. Is this the expected behavior? I've observed it on kamailio 5.3 and 5.5 releases.

My dispatcher.list:

# Group 1
1 sip:127.0.0.1:5071;transport=udp 8 0
# Group 2
2 sip:127.0.0.1:5072;transport=udp 8 0
# Group 3
3 sip:127.0.0.1:7010;transport=udp 8 0
3 sip:127.0.0.1:7011;transport=udp 8 0
3 sip:127.0.0.1:7012;transport=udp 8 0
# Group 4
4 sip:127.0.0.1:5071;transport=udp 8 0
4 sip:127.0.0.1:5072;transport=udp 8 0

I have the following in failure_route (excerpt):

                    $var(dsFoundDestination) = 0;

                        if (t_any_replied())
                        {
                            xavp_params_implode("_dsdst_", "$var(dsDestinations)");
                            xlog("L_INFO", "FAILURE ROUTE: Already have replies on this transaction. Selecting next destination from: [$var(dsDestinations)]");
                            if (ds_next_dst())
                            {
                                xavp_params_implode("_dsdst_", "$var(dsDestinations)");
                                xlog("L_INFO", "FAILURE ROUTE: Next destination selected: [$du] from [$var(dsDestinations)]");
                                $var(dsFoundDestination) = 1;
                            }
                        }
                        else if (ds_select_dst("3", "8")) // Dispatcher Group 3
                        {
                            xlog("L_INFO", "FAILURE ROUTE: Did not find any replies on this transaction. Selected destination: [$du]");
                            $var(dsFoundDestination) = 1;
                        }
                        if ($var(dsFoundDestination))
                        {
                            $var(logString) = "FAILURE ROUTE: Relayed to [" + $du + "]";
                            if (t_relay())
                            {
                                xlog("L_INFO", "$var(logString)");
                            }
                        }

Produces the following logs:

FAILURE ROUTE: Did not find any replies on this transaction. Selected destination: [sip:127.0.0.1:7012;transport=udp]
FAILURE ROUTE: Relayed to [sip:127.0.0.1:7012;transport=udp]
FAILURE ROUTE: Already have replies on this transaction. Selecting next destination from: [grp=3;uri=sip:127.0.0.1:7012;transport=udp;]
FAILURE ROUTE: Next destination selected: [sip:127.0.0.1:7011;transport=udp] from [grp=3;uri=sip:127.0.0.1:7011;transport=udp;]
FAILURE ROUTE: Relayed to [sip:127.0.0.1:7011;transport=udp]
FAILURE ROUTE: Already have replies on this transaction. Selecting next destination from: [grp=3;uri=sip:127.0.0.1:7011;transport=udp;]
FAILURE ROUTE: Next destination selected: [sip:127.0.0.1:7010;transport=udp] from [grp=3;uri=sip:127.0.0.1:7010;transport=udp;]
FAILURE ROUTE: Relayed to [sip:127.0.0.1:7010;transport=udp]
FAILURE ROUTE: Already have replies on this transaction. Selecting next destination from: [grp=3;uri=sip:127.0.0.1:7010;transport=udp;]
FAILURE ROUTE: Next destination selected: [sip:127.0.0.1:5072;transport=udp] from [grp=2;uri=sip:127.0.0.1:5072;transport=udp;]
FAILURE ROUTE: Relayed to [sip:127.0.0.1:5072;transport=udp]
FAILURE ROUTE: Already have replies on this transaction. Selecting next destination from: [grp=2;uri=sip:127.0.0.1:5072;transport=udp;]
FAILURE ROUTE: Next destination selected: [sip:127.0.0.1:5072;transport=udp] from [grp=2;uri=sip:127.0.0.1:5072;transport=udp;]
FAILURE ROUTE: Relayed to [sip:127.0.0.1:5072;transport=udp]
FAILURE ROUTE: Already have replies on this transaction. Selecting next destination from: [grp=2;uri=sip:127.0.0.1:5072;transport=udp;]
FAILURE ROUTE: Next destination selected: [sip:127.0.0.1:5071;transport=udp] from [grp=1;uri=sip:127.0.0.1:5071;transport=udp;]
FAILURE ROUTE: Relayed to [sip:127.0.0.1:5071;transport=udp]

I want to stop the loop once there are no more active destinations in group 3. Is the solution simply to check that the selected destination is part of the desired group and stop processing if it is not?

Thanks for your time.
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe: