Hello,

 

the same From URI will always hash to the same server with this algorithm. Have you tested with different URIs (user), or only with one user? Over multiple users it should balance out to a fair distribution.

 

Cheers,

 

Henning

 

--

Henning Westerholt – https://skalatan.de/blog/

Kamailio services – https://gilawa.com

 

From: Shah Hussain Khattak <shahhusayn@msn.com>
Sent: Dienstag, 4. Juli 2023 09:40
To: Henning Westerholt <hw@gilawa.com>; Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: Re: Using Kamailio in front of Freeswitch for load balancing REG and Calls

 

Sweet! Henning, thank you very much for the update, it was very helpful. 

 

As I am new to the Kamailio, I was able to set up the basic routing now, but for some reason, my registration requests are always going to the first gateway. My routing block looks like this:

 

# Handle SIP registrations

route[REGISTRAR] {

        if(!is_method("REGISTER"))

                return;

        add_path_received();

 

        # Use From URI hash for dispatching

        if (!ds_select_dst("1", "1")) {

                send_reply("404", "No destination");

                exit;

        }

 

        xdbg("--- SCRIPT: going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))\n");

        t_on_failure("RTF_DISPATCH");

        route(RELAY);

        exit;

}

 

# Dispatch requests

route[DISPATCH] {

        # round robin dispatching on gateways group '1'

        if(!ds_select_dst("1", "1")) {

                send_reply("404", "No destination");

                exit;

        }

        xdbg("--- SCRIPT: going to <$ru> via <$du> (attrs: $xavp(_dsdst_=>attrs))\n");

        t_on_failure("RTF_DISPATCH");

        route(RELAY);

        exit;

}

 

my dispatcher file configs are quite simple:

 

1 sip:172.16.8.4;transport=udp 0 0

1 sip:172.16.8.5;transport=udp 0 0

 

 

Can you please advise what config is missing here so I can load balance the registrations and calls properly? For example, I would like both the gateways to handle 50% of the load. Sorry if I am missing something very basic here. 

 

 

Regards, 

Shah Hussain 

 

 

 


From: Henning Westerholt <hw@gilawa.com>
Sent: Monday, July 3, 2023 4:59 PM
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Cc: Shah Hussain Khattak <shahhusayn@msn.com>
Subject: RE: Using Kamailio in front of Freeswitch for load balancing REG and Calls

 

Hello,

 

for authentication you should not use round-robin, for the observed reasons.

 

You could e.g., hash over the from URI, then all requests should end up on the same freeswitch for the authentication to work.

 

Here is an (old) discussion with some more content:

https://lists.kamailio.org/pipermail/devel/2008-September/016234.html

 

 

Cheers,

 

Henning

 

--

Henning Westerholt – https://skalatan.de/blog/

Kamailio services – https://gilawa.com

 

From: Shah Hussain Khattak <shahhusayn@msn.com>
Sent: Montag, 3. Juli 2023 08:08
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: [SR-Users] Using Kamailio in front of Freeswitch for load balancing REG and Calls

 

Hello Awesome people, 

 

I have configured Kamailio in front of two Freeswitch servers. I am using the dispatcher module to load and balance the traffic between the two FS boxes. My dispatcher is configured in a round-robin fashion. 

 

If I send a register to my FS servers, the re-register post-challenge (401) message is routed to the second FS server and the registration fails. I want to check with you guys how are you handling this in your setups. I am sure a lot of companies are using Kamailio to load balance traffic toward the FS and Asterisk servers. 

 

UAC --- > Kamailio --- > FS1 

REG ---- > REG ---- > REG 

401 <---- 401 < ---- 401

 

re-register with authorization data:

UAC --- > Kamailio --- > FS2 

REG --- > REG  ---- > REG 

401 <---- 401 < ---- 401

 

it just create this loop and register fails. 

 

Ideally, I want Kamailio to send the re-register (with auth data) to the same FS server that challenged it. 

 

Any ideas or pointers to fix this issue would be highly appreciated, maybe I am missing some very basic configuration. Or maybe there is another simpler way instead of using a dispatcher module. 

 

 

Thank you! 

 

Regards, 

Shah Hussain