load balancer module to asterisk servers

  • Lui

    Lui - 2012-11-07

    Hi Admin.

    I followed the guide on this page and managed to install and configured everything.

    1. Install Opensips
    2. Configure Opensips Load Balancer Script via the generate scripts for load balancer.
    3. Configure Load_Balancer table in mysql to insert the asterisk server IPs.
    4. Restart Opensips. (no errors)
    5. Login on my softphone using one of the users of the asterisk server and changing the domain to opensips. (not working)

    Do I need to configure an opensips extension in the asterisk sip.conf so that it can connect to the asterisk servers?


  • Lui

    Lui - 2012-11-07

    Hi Admin,

    Here's what i'm trying to do. I want to create a farm of asterisk servers with opensips acting as the front end. Then Load Balancing them depending on the load of calls per asterisk server.  Do I still need to configure something on the asterisk servers so that opensips can make the load balancer module work? I appreciate your reply.

    1. opensips
    2. asterisk 1
    3. asterisk 2
    4. asterisk 3


  • apsaras

    apsaras - 2013-01-06

    Hello Lui

    There are many ways to implement what you are trying. If the OpenSIPs only does load balancing then you have to insert all users at asterisk database and forward everyting to Asterisk. In that case you need to have a sip trunk between OpenSIPs and Asterisk.

    If you want to have OpenSIPs to act as Registrar then you have to integrade OpenSIPs Subscription Database table with sip_users Database table of Asterisk in order to have one repository of users. Moreover you should have a script on OpenSIPs which will be aware of calls comming from Asterisk to users and calls comming from users to Asterisk.

  • Avestan

    Avestan - 2013-01-06

    Hello asterlui,

    I wish you have had provided more information on your current set-up and what it is that you wish to achieve.

    I am going to take a moment and see if I can break down your set-up and what it is that you wish to achieve. Please feel free to correct me if I am wrong.

    You have said:

    1. you have a farm of Asterisk boxes which are going to deal with processing calls.
    2. You wish to load balance the calls between the asterisk boxes. Consequently, you wish opensips to receive the calls and distributes them among the asterisk boxes.  That is down based on the information that you have in the opensips "Load_Balance" table.
    3. You have set your Soft-phone to point to the opensips (IP address - Domain Name).
    4. It doesn't work!

    You have not said:

    1. Who is going to do the user registration?  OpenSIPS or Asterisk Boxes?
    2. Where the calls are made to and where the Calls are coming from?
    1. Are you intending to allow your soft-phones (Users) make call to none VoIP environment (other users on your VoIP Network) such as PSTN.

    2. Do you have DIDs which you are going to receive calls on them and you need to also process those calls?

    Making the long story short.  The Load_Balancer Module and the automatic configuration generated by the script is not going to work for you as it is as it doesn't deal with Registration or Redirecting Registration to an asterisk box.

    The Load_Balancer module is module and the automatic generated configuration file is for receiving initial requests such as  "Invite". Please have a look at the configuration file and if I am not mistaken you should be able to find the following:

            #### INITIAL REQUESTS

            # CANCEL processing
            if (is_method("CANCEL")) {
                    if (t_check_trans())
            } else if (!is_method("INVITE")) {
                    send_reply("405","Method Not Allowed");

            if ($rU==NULL) {
                    # request with no Username in RURI
                    sl_send_reply("484","Address Incomplete");


    Making the long story, the OpenSIPS is capable of various scenarios and you need to configure it in order to work for your set-up.  Therefore, if you provide detail about what it is that you wish to achieve with your set-up them it would be possible to help you out.  The OpenSIPS can carry-out the Registration itself or can pass on the Registration to Asterisk box. It has to be configured to do it and your current configuration file (again assuming it is the automatically generated configuration file) is not capable to do so.



  • Avestan

    Avestan - 2013-01-06

    Hello asterlui,

    now you may ask, what is it the configuration file is configures the OPenSIPS to do as it is in your case (Automatically generated Load_Balancer configuration?!

    If you have a DIDs, point your DIDs to the OpenSIPS and make conceren call and the OpenSIPS will gladly load balanced your calls among your asterisk boxes based on the information you have provided in the Load_Balanced table of opensips database.