[OpenSIPS-Users] basic load balancer setup

Joshua Nankin jnankin at gmail.com
Tue Mar 13 21:00:19 CET 2012


Hello,

Trying to use OpenSIPS as both a load balancer for incoming calls and
as an outbound proxy to my carrier.  I have been unsuccessful to place
outgoing or incoming calls, and I think I just need some help with the
configuration.  Just for testing, I have one Asterisk box behind
OpenSIPS and the load balancer table on OpenSIPS looks like this:

+----+----------+-------------------+-----------+------------+-------------+
| id | group_id | dst_uri           | resources | probe_mode | description |
+----+----------+-------------------+-----------+------------+-------------+
|  1 |        1 | sip:10.36.115.119 | fax=300   |          0 | tester      |
+----+----------+-------------------+-----------+------------+-------------+


The dst_ur is the internal IP of my asterisk box.  I'm using this for
fax, so I have set the resources field to 300 channels of "fax".   On
my asterisk box, I've added "outboundproxy=23.21.170.154", as the 23.*
IP is the external IP of the opensips box.  Below is my simple
opensips.cfg that I've adapted from the load balancing tutorial.  Any
help would be much appreciated.  Additionally, for debugging purposes,
I've opened all UDP and TCP ports.  Still not able to connect.


debug=6
memlog=1

fork=yes
children=2
log_stderror=yes
log_facility=LOG_LOCAL0

disable_tcp=yes
disable_dns_blacklist = yes

auto_aliases=no

check_via=no
dns=off
rev_dns=off
port=5060

mpath="/usr/lib/opensips/modules/"
loadmodule "maxfwd.so"
loadmodule "sl.so"
loadmodule "db_mysql.so"
loadmodule "tm.so"
loadmodule "uri.so"
loadmodule "rr.so"
loadmodule "dialog.so"
loadmodule "mi_fifo.so"
loadmodule "signaling.so"
loadmodule "textops.so"
loadmodule "load_balancer.so"

modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
modparam("mi_fifo", "fifo_mode",0666)

modparam("dialog", "db_mode", 1)
modparam("dialog", "db_url", "mysql://root:opensips@localhost/opensips")

modparam("rr","enable_double_rr",1)
modparam("rr","append_fromtag",1)

modparam("load_balancer", "db_url","mysql://root:opensips@localhost/opensips")


route{
	if (!mf_process_maxfwd_header("3")) {
		sl_send_reply("483","looping");
		exit;
	}


	if (!has_totag()) {
                # initial request
		record_route();
	} else {
		# sequential request -> obey Route indication
		loose_route();
                t_relay();
                exit;
        }

        # handle cancel and re-transmissions
	if ( is_method("CANCEL") ) {
		if ( t_check_trans() )
			t_relay();
		exit;
	}


        # from now on we have only the initial requests
        if (!is_method("INVITE")) {
                send_reply("405","Method Not Allowed");
                exit;
        }

        # detect resources and do balancing
       load_balance("1","fax");

        # LB function returns negative if no suitable destination (for
requested resources) is found,
        # or if all destinations are full
        if ($retcode<0) {
             sl_send_reply("500","Service full");
             exit;
        }

	xlog("Selected destination is: $du\n");

        # send it out
	if (!t_relay()) {
		sl_reply_error();
	}
}



More information about the Users mailing list