Hi,

Here is a simpler easiler solution for your case.

Prerequisits:
1. Media gateways should register for somewhat longer period of time, e.g. 3600 seconds (shorter intervals would work too but longer is better).
2. All media gateways should register to kamailio through same kamailio listen socket (if they register through different kamailio sockets then it would add further complication since then you have to manage forced socket too in dispatcher module).


Method:
1. Enable dispatcher module with db backend.
https://kamailio.org/docs/modules/5.0.x/modules/dispatcher.html#dispatcher.p.db_url

2. Enable received_avp in registrar module, (you can work without it but then you need to create and manage received avp yourself).
https://kamailio.org/docs/modules/5.0.x/modules/registrar.html#registrar.p.received_avp

3. When any media gateway registers with kamailio successfully. You should have received_avp filled up. Use SQLOps module to insert this in dispatcher module.

4. Reload dispatcher db,
https://kamailio.org/docs/modules/5.0.x/modules/dispatcher.html#dispatcher.f.ds_reload

Now you have a working load balancing setup for your MGs valid till their sip register expiry. You can choose whatever load balancing algorithm you like.

5. For media gateway re-register, step 4 & 5 are not required.

6. When any media gateway un-registers or registration expires, remove the entry in dispatcher table and reload.
https://kamailio.org/docs/modules/5.0.x/modules/registrar.html#idp23888404


Hope this helps.


Thank you.



On Thu, Nov 23, 2017 at 5:57 PM, SamyGo <govoiper@gmail.com> wrote:
Hi. 
So thats what I've done already before posting this question; even if I've to do loadbalancing I can use the "fetch_registered_contacts" function, loop over the online gateways on that 1 RURI and "append_branches()" with sorted "q" values... 

That all depends on the accurate measurement of the number of active calls, since requirement is to perform load-balancing based on call loads. Simple load-balancing can be achieved already by manipulating "q" values....again too complicated to work accurately 100% of the time. 

I'm trying to figure out way to totally avoid this use-case at all.

Regards,
Sammy


On Thu, Nov 23, 2017 at 11:36 AM, Daniel Tryba <d.tryba@pocos.nl> wrote:
On Thu, Nov 23, 2017 at 12:14:36AM -0500, SamyGo wrote:
> I've a scenario where multiple mediaservers will be registered to Kamailio
> and for any incoming call from Upstream provider I've to perform
> load-balancing to the actively registered media-servers.
>
> dispatcher module does load-balancing for IP endpoints, is there any other
> module where I can perform load-balancing on registered
> clients(media-servers)?

If you have those mediaserver register with the same username you could
simply use lookup and  serial forking to loadbalance. No idea how to
randomize the results from lookup though.


_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users