<html><head></head><body><div>What comes from the load balancer, should not be send back to the load balancer. Add condition before you load balance.<br><br><div class="acompli_signature">Get <a href="https://aka.ms/o0ukef">Outlook for iOS</a></div><br></div><br><br><br>
<div class="gmail_quote">On Thu, May 26, 2016 at 10:08 PM -0700, "Francjos" <span dir="ltr"><<a href="mailto:35633@heb.be" target="_blank">35633@heb.be</a>></span> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="3D"ltr"">
<pre>I've configured two opensips to load balance incoming calls to freeswitch
servers.One of the two opensips works welle and routes calls to the
destination, but another causes the error "Too many hops".
I have the same configuration file for the two opsnisps.
Any help?
Here is the configuration file:
opensips.cfg
####### Global Parameters #########
#debug=3
debug=4
log_stderror=yes
log_facility=LOG_LOCAL0
fork=yes
children=4
/* uncomment the following lines to enable debugging */
#debug=6
#fork=no
#log_stderror=yes
/* uncomment the next line to enable the auto temporary blacklisting of
not available destinations (default disabled) */
#disable_dns_blacklist=no
/* uncomment the next line to enable IPv6 lookup after IPv4 dns
lookup failures (default disabled) */
#dns_try_ipv6=yes
/* comment the next line to enable the auto discovery of local aliases
based on revers DNS on IPs */
auto_aliases=no
mhomed=yes
#listen=udp:127.0.0.1:5060 # CUSTOMIZE ME
listen=udp:10.0.0.5:5060
####### Modules Section ########
#set module path
mpath="/usr/lib/opensips/modules/"
##### DB_MYSQL module
loadmodule "db_mysql.so"
modparam("db_mysql", "exec_query_threshold", 600000)
modparam("db_mysql", "timeout_interval", 2)
##### UAC_AUTH module: Authentication module
loadmodule "uac_auth.so"
modparam("uac_auth", "credential", "username:10.0.0.5:password")
###### UAC_REGISTRANT module: module of registration on a remote server
loadmodule "uac_registrant.so"
modparam("uac_registrant", "hash_size", 2)
modparam("uac_registrant", "timer_interval", 100)
modparam("uac_registrant", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")
modparam("uac_registrant", "table_name", "registrant")
modparam("uac_registrant", "registrar_column", "registrar")
modparam("uac_registrant", "proxy_column", "proxy")
modparam("uac_registrant", "aor_column", "aor")
modparam("uac_registrant", "third_party_registrant_column",
"third_party_registrant")
modparam("uac_registrant", "username_column", "username")
modparam("uac_registrant", "password_column", "password")
modparam("uac_registrant", "binding_URI_column", "binding_URI")
modparam("uac_registrant", "binding_params_column", "binding_params")
modparam("uac_registrant", "expiry_column", "expiry")
modparam("uac_registrant", "forced_socket_column", "forced_socket")
#### SIGNALING module
loadmodule "signaling.so"
#### StateLess module
loadmodule "sl.so"
#### Transaction Module
loadmodule "tm.so"
modparam("tm", "fr_timeout", 5)
modparam("tm", "fr_inv_timeout", 30)
modparam("tm", "restart_fr_on_each_reply", 0)
modparam("tm", "onreply_avp_mode", 1)
#### Record Route Module
loadmodule "rr.so"
/* do not append from tag to the RR (no need for this script) */
modparam("rr", "append_fromtag", 0)
#### MAX ForWarD module
loadmodule "maxfwd.so"
#### SIP MSG OPerationS module
loadmodule "sipmsgops.so"
#### FIFO Management Interface
loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
modparam("mi_fifo", "fifo_mode", 0666)
###### Text Operations Module
loadmodule "textops.so"
#### URI module
loadmodule "uri.so"
modparam("uri", "use_uri_table", 0)
modparam("uri", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
#### USeR LOCation module
loadmodule "usrloc.so"
modparam("usrloc", "nat_bflag", "NAT")
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")
#### REGISTRAR module
loadmodule "registrar.so"
/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam("registrar", "max_contacts", 10)
modparam("registrar", "tcp_persistent_flag", 7)
#### ACCounting module
loadmodule "acc.so"
/* what special events should be accounted ? */
modparam("acc", "early_media", 0)
modparam("acc", "report_cancels", 0)
/* by default we do not adjust the direct of the sequential requests.
if you enable this parameter, be sure the enable "append_fromtag"
in "rr" module */
modparam("acc", "detect_direction", 0)
modparam("acc", "failed_transaction_flag", "ACC_FAILED")
/* account triggers (flags) */
modparam("acc", "log_flag", "ACC_DO")
modparam("acc", "log_missed_flag", "ACC_MISSED")
#########AUTHentication modules
loadmodule "auth.so"
loadmodule "auth_db.so"
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db",
"db_url","mysql://opensips:opensipsrw@localhost/opensips") # CUSTOMIZE ME
modparam("auth_db", "load_credentials", "")
########### Doamian module
loadmodule "domain.so"
modparam("domain",
"db_url","mysql://opensips:opensipsrw@localhost/opensips")
modparam("domain", "db_mode", 1) # Use caching
modparam("domain", "domain_table", "domain")
modparam("domain", "domain_col", "domain_name")
modparam("domain", "attrs_col", "attributes")
modparam("auth_db|usrloc|uri", "use_domain", 1)
######## DIALOG module
loadmodule "dialog.so"
modparam("dialog", "dlg_match_mode", 1)
modparam("dialog", "default_timeout", 21600) # 6 hours timeout
modparam("dialog", "db_mode", 2)
modparam("dialog",
"db_url","mysql://opensips:opensipsrw@localhost/opensips") # CUSTOMIZE ME
##### RTPPROXY module
loadmodule "rtpproxy.so"
modparam("rtpproxy", "rtpproxy_sock", "udp:10.0.0.5:37000")
###### AVPs operations module
loadmodule "avpops.so"
modparam("avpops", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")
modparam("avpops", "avp_table", "New_usr_preferences")
modparam("avpops", "use_domain", 1)
##### NATHELPER module
loadmodule "nathelper.so"
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "received_avp", "$avp(i:42)")
modparam("nathelper", "sipping_bflag", 7)
modparam("nathelper", "sipping_from", "sip:opensips@10.0.0.5")
####### Load_balancer module
loadmodule "load_balancer.so"
#ping every 30 secs the failesd destinations
modparam("load_balancer", "probing_interval", 30)
modparam("load_balancer", "probing_method", "OPTIONS")
modparam("load_balancer", "db_table", "load_balancer")
# consider positive ping reply the 404
modparam("load_balancer", "probing_reply_codes", "501, 404")
modparam("load_balancer", "probing_from", "sip:opensips@10.0.0.5")
modparam("load_balancer", "db_url",
"mysql://opensips:opensipsrw@localhost/opensips")
#### UDP protocol
loadmodule "proto_udp.so"
####### Routing Logic ########
# main request routing logic
route {
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
}
if (nat_uac_test("19")) {
xlog("L_INFO","[$pr:$fU@$si:$sp]: NAT Detection Test-19
Passed Now Fixing-Nat for '$rm' \n");
if (is_method("REGISTER")) {
fix_nated_register();
} else {
fix_nated_contact();
}
xlog("L_INFO","[$pr:$fU@$si:$sp]: NAT Fixed for '$rm' \n");
setflag(5);
};
if (has_totag()) {
# sequential requests within a dialog should
# take the path determined by record-routing and obey Route
indication
if (loose_route()) {
if(is_method("BYE")) {
setflag(ACC_DO); # do accounting ...
setflag(ACC_FAILED); # ... even if the
transaction fails
unforce_rtp_proxy(); ###### AJOUTE PAR MOI
} else if (is_method("INVITE")) {
# even if in most of the cases is useless,
do RR for
# re-INVITEs alos, as some buggy clients do
change route set
# during the dialog.
record_route();
}
# route it out to whatever destination was set by
loose_route()
# in $du (destination URI).
route(relay);
} else {
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# non loose-route, but stateful ACK;
must be an ACK after
# a 487 or e.g. 404 from upstream
server
t_relay();
exit;
} else {
# ACK without matching transaction
->
# ignore and discard
exit;
}
}
sl_send_reply("404","Not here");
}
exit;
}
# CANCEL processing
if (is_method("CANCEL"))
{
if (t_check_trans())
t_relay();
exit;
}
t_check_trans();
if ( !(is_method("REGISTER") ) ) {
if (from_uri==myself)
{
}else{
#if caller is not local, then called number must be
local
if(!uri==myself){
send_reply("403", "Relay forbidden");
exit;
}
}
}
# preloaded route checking
if (loose_route()) {
xlog("L_ERR",
"Attempt to route with preloaded Route's
[$fu/$tu/$ru/$ci]");
if (!is_method("ACK"))
sl_send_reply("403","Preload Route denied");
exit;
}
# record routing
if (!is_method("REGISTER|MESSAGE"))
record_route();
# account only INVITEs
if (is_method("INVITE")) {
setflag(ACC_DO); # do accounting
}
if (!uri==myself) {
append_hf("P-hint: outbound\r\n");
route(relay);
}
# requests for my domain
if (is_method("PUBLISH|SUBSCRIBE"))
{
sl_send_reply("503", "Service Unavailable");
exit;
}
if (is_method("REGISTER"))
{
if (!save("location"))
sl_reply_error();
exit;
}
if ($rU==NULL) {
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
exit;
}
### FREESWITCH
# Do lookup with method filtering
xlog("L_NOTICE","[$pr:$fU@$si:$sp]: Call from '$fu' to '$ru' LOOKUP
in 'Location' table\n");
if(!lookup("location", "m")){
switch ($retcode) {
case -1:
case -3:
t_newtran();
#t_reply("404", "Not Found");
xlog("L_NOTICE","[$pr:$fU@$si:$sp]: Call
from '$fu' to '$ru' User Not Found - try Dialing Media-Server\n");
route(2);
route(relay);
case -2:
sl_send_reply("405", "Method Not Allowed");
exit;
}
}
# when routing via usrloc, log the missed calls also
#setflag(ACC_MISSED);
#setflag(2);
route(relay);
}
route[relay] {
# for INVITEs enable some additional helper routes
if (is_method("INVITE")) {
t_on_branch("per_branch_ops");
t_on_reply("handle_nat");
t_on_failure("missed_call");
if (isflagset(5)) {
xlog("L_NOTICE","[$pr:$fU@$si:$sp]: Engage
Media-Proxy here\n");
xlog("L_NOTICE","[$pr:$fU@$si:$sp]:
InBound-OR-OutBound Call Check!!\n");
if(avp_db_query("select dst_uri from load_balancer
where dst_uri like '%$dd%'")){
#INCOMING CALL NEEDS TO GOTO PRIVATE-IP FreeSWITCH
USE - IE
engage_rtp_proxy("rie");
}else if(avp_db_query("select dst_uri from
load_balancer where dst_uri='sip:$si:$sp'")){
#INCOMING CALL FROM PRIVATE-IP FreeSWITCH USE - EI
engage_rtp_proxy("rei");
}else{
engage_rtp_proxy("r");
}
}
}
if (!t_relay()) {
send_reply("500","Internal Error");
};
exit;
}
## Freeswitch
route[2] {
xlog("L_NOTICE","[$pr:$fU@$si:$sp]: This is Media-Server Route Use
Load-balancer NOW!!\n");
#if (!load_balance("1","calls")) {
# sl_send_reply("500","Service full");
# exit;
#}
if(load_balance("1", "calls", "1")){
#dst URI points to the new destination
xlog("Sending call to $du\n");
t_relay();
exit;
}else{
if(is_method("OPTIONS")){
sl_send_reply("200", "OK");
exit;
}
}
xlog("L_NOTICE","[$pr:$fU@$si:$sp]: Selected destination
Media-Server : $du\n");
}
route[REGISTRAR] {
if(is_method("REGISTER")){
xlog("Main route: Manage REGISTER requests: $fU");
if(isflagset(FLI_NATS)){
setbflag(FLB_NATB);
}
if(!save("location")){
sl_reply_error();
}
}
}
branch_route[per_branch_ops] {
xlog("new branch at $ru\n");
}
onreply_route[handle_nat] {
xlog("incoming reply\n");
}
failure_route[missed_call] {
if (t_was_cancelled()) {
exit;
}
# uncomment the following lines if you want to block client
# redirect based on 3xx replies.
##if (t_check_status("3[0-9][0-9]")) {
##t_reply("404","Not found");
## exit;
##}
}
--
View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/Too-many-Hops-error-tp7603151.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
</pre>
</div>
</blockquote>
</div>
</body></html>