Ok i got part of it to work:

    if(ds_select_routes("1=10;11=9", "D", "10"))
 
The first 2 setid nodes are filled until the maxload value, looks good:

DEBUG: dispatcher [dispatcher.c:679]: ki_ds_select_routes_limit(): routing with setid=1 alg=10 cnt=0 limit=0xa (10)
DEBUG: dispatcher [dispatch.c:2044]: ds_manage_routes(): set [1]
DEBUG: dispatcher [dispatch.c:2148]: ds_manage_routes(): using alg [10] hash [1]
DEBUG: dispatcher [dispatch.c:2188]: ds_manage_routes(): selected [10-1-0/1] <sip:1.1.1.1:5080>
DEBUG: dispatcher [dispatch.c:2207]: ds_manage_routes(): using first entry [1/1]
DEBUG: dispatcher [dispatcher.c:679]: ki_ds_select_routes_limit(): routing with setid=11 alg=9 cnt=1 limit=0xa (10)
DEBUG: dispatcher [dispatch.c:2044]: ds_manage_routes(): set [11]
DEBUG: dispatcher [dispatch.c:2148]: ds_manage_routes(): using alg [9] hash [0]
DEBUG: dispatcher [dispatch.c:2188]: ds_manage_routes(): selected [9-11-2/0] <sip:2.2.2.2:5080>
DEBUG: dispatcher [dispatch.c:2207]: ds_manage_routes(): using first entry [11/0]
DEBUG: dispatcher [dispatcher.c:738]: ki_ds_select_routes_limit(): selected target destinations: 2
exec: *** cfgtrace:request_route=[DISPATCH] c=[/usr/local/kamailio5/etc/kamailio/kamailio.cfg] l=1067 a=26 n=xlog
DEBUG: <script>: [DISPATCH] 4-4850@192.168.1.201: ds_select_dst was succesful (ruri: sip:*TESTCALL@proxy.domain.com - du: <sip:1.1.1.1:5080>)
exec: *** cfgtrace:request_route=[DISPATCH] c=[/usr/local/kamailio5/etc/kamailio/kamailio.cfg] l=1072 a=16 n=if
exec: *** cfgtrace:request_route=[DISPATCH] c=[/usr/local/kamailio5/etc/kamailio/kamailio.cfg] l=1077 a=26 n=xlog
DEBUG: <script>: --- SCRIPT: 4-4850@192.168.1.201: going to <sip:*TESTCALL@cuore-proxy.sandbox-sngl.com> via <sip:1.1.1.1:5080>

 but then, when they are full, kamailio fails to set a destination URI:

DEBUG: dispatcher [dispatcher.c:679]: ki_ds_select_routes_limit(): routing with setid=11 alg=9 cnt=0 limit=0xa (10)
DEBUG: dispatcher [dispatch.c:2044]: ds_manage_routes(): set [11]
DEBUG: dispatcher [dispatch.c:2148]: ds_manage_routes(): using alg [9] hash [0]
DEBUG: dispatcher [dispatch.c:2188]: ds_manage_routes(): selected [9-11-2/0] <sip:2.2.2.2:5080>
DEBUG: dispatcher [dispatch.c:2207]: ds_manage_routes(): using first entry [11/0]
DEBUG: dispatcher [dispatcher.c:738]: ki_ds_select_routes_limit(): selected target destinations: 1
exec: *** cfgtrace:request_route=[DISPATCH] c=[/usr/local/kamailio5/etc/kamailio/kamailio.cfg] l=1067 a=26 n=xlog
DEBUG: pv [pv_core.c:1351]: pv_get_dsturi(): no destination URI
DEBUG: <script>: [DISPATCH] 5-4850@192.168.1.201: ds_select_dst was succesful (ruri: sip:*TESTCALL@proxy.domain.com - du: <<null>>)
exec: *** cfgtrace:request_route=[DISPATCH] c=[/usr/local/kamailio5/etc/kamailio/kamailio.cfg] l=1072 a=16 n=if
DEBUG: pv [pv_core.c:1351]: pv_get_dsturi(): no destination URI


Can you think of why?


Thanks All!




Regards,

David Villasmil
phone: +34669448337


On Fri, Nov 16, 2018 at 5:32 PM David Villasmil <david.villasmil.work@gmail.com> wrote:
sorry, instead of ruri, i use destination.

Regards,

David Villasmil
phone: +34669448337


On Fri, Nov 16, 2018 at 5:31 PM David Villasmil <david.villasmil.work@gmail.com> wrote:
Hello Daniel,

I compiled and i'm testing 5.2, but it doesn't seem to be doing what I was expecting, my config is as follows:

route[DISPATCH] {
    dp_match("1", "$ru");

    if(!ds_select_routes("1=4;11=9", "ruri", "10"))
    {
        send_reply("404", "No destination");
        exit;
    } else {
        xlog("[DISPATCH] ds_select_dst was succesful\n");
    }
    xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");
    t_on_failure("RTF_DISPATCH");
    route(RELAY);
    exit;
}

And my table is:

+----+-------+------------------------------------+-------+----------+----------------------------+-------------+
| id | setid | destination                        | flags | priority | attrs                      | description |
+----+-------+------------------------------------+-------+----------+----------------------------+-------------+
| 213 |     1 | sip:34.201.28.49:5080              |     0 |       10 | weight=100                | node1-proxy |
| 229 |     1 | sip:54.209.229.198:5080            |     0 |       10 | weight=100                | node2-proxy |
| 232 |    11 | sip:35.170.67.206:5080             |     0 |       10 | weight=100                | node3-proxy |
+----+-------+------------------------------------+-------+----------+----------------------------+-------------+

But kamailio is always sending to the same ip 198, although it should be load-balancing round-robin to the 2 nodes on setid 1. And when those 2 nodes have 10 calls, then start sending to setid 11.

Is my config wrong?

Regards,

David Villasmil
phone: +34669448337


On Thu, Nov 15, 2018 at 4:09 PM David Villasmil <david.villasmil.work@gmail.com> wrote:
Ah, 5.2 branch. Will test it, thanks!

On Thu, 15 Nov 2018 at 16:06, Daniel-Constantin Mierla <miconda@gmail.com> wrote:

Hello,

besides master, you can also use branch 5.2 -- this is going to be used to release 5.2.0 and other future 5.2.x versions. Those two branches have the same version of the module at this moment.

Cheers,
Daniel

On 15.11.18 16:48, David Villasmil wrote:
Hey Daniel,

Thanks for replying. Can I test this from master?

David
On Thu, 15 Nov 2018 at 15:12, Daniel-Constantin Mierla <miconda@gmail.com> wrote:
Hello,


On 14.11.18 23:16, David Villasmil wrote:
> Hello,
>
> Is it possible to set an algorithm like the following?
>
> fs1 - Priority 10 - maxload 20 calls
> fs2 - Priority 10 - maxload 20 calls
> fs3 - Priority 9 - maxload 20 calls
> fs4 - Priority 8 - maxload 20 calls
> fs5 - Priority 7 - maxload 20 calls
>
> So that, whenever any new call comes in, fs1 and fs2 would be used,
> meaning the fs with the highest priority would be use UNLESS there's
> 20 calls on that server, in which case, the next server with the
> highest priority would be used.
>
this should be easier possible with the upcoming 5.2.0 (to be released
in about 2 weeks or so), see:

  -
https://www.kamailio.org/docs/modules/devel/modules/dispatcher.html#dispatcher.f.ds_select_routes

For older versions you may need to do more complex logic in the
configuration file to call dispatcher for different groups at different
stages of failure re-routing.

Cheers,
Daniel

--
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com
Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- www.asipto.com

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference -- www.kamailioworld.com
Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- www.asipto.com