Please, check mi configuration

monica
2011-09-09
2013-05-09
  • monica
    monica
    2011-09-09

    Hi, this is my first server OpenSIPS.

    I configured load_balancer and nathelper with rtpproxy.

    OpenSIPS -> 209.190.36.146
    Asterisk 1.6 -> 189.90.138.174
    astersk 1.6 -> 200223167139

    Please check mi config


    ####### Global Parameters #########

    debug=3
    log_stderror=no
    log_facility=LOG_LOCAL0

    fork=yes
    children=2

    disable_tcp=yes

    port=5060

    listen=udp:209.190.36.146:5060

    ####### Modules Section ########

    #set module path
    mpath="//lib/opensips/modules/"

    loadmodule "db_mysql.so"
    loadmodule "signaling.so"
    loadmodule "sl.so"
    loadmodule "tm.so"
    loadmodule "maxfwd.so"
    loadmodule "avpops.so"
    loadmodule "usrloc.so"
    loadmodule "auth.so"
    loadmodule "registrar.so"
    loadmodule "textops.so"
    loadmodule "mi_fifo.so"
    loadmodule "uri.so"
    loadmodule "rr.so"
    loadmodule "acc.so"
    loadmodule "domain.so"
    loadmodule "load_balancer.so"
    loadmodule "dialog.so"
    loadmodule "auth_db.so"
    loadmodule "nathelper.so"

    modparam("nathelper", "rtpproxy_sock", "udp:127.0.0.1:7890")
    modparam("nathelper", "natping_interval", 10)
    modparam("nathelper", "ping_nated_only", 0)
    modparam("nathelper", "sipping_bflag", 7)
    modparam("nathelper", "sipping_from", "sip:pinger@209.190.36.146")
    modparam("nathelper", "rtpproxy_timeout", "0.2")

    modparam("registrar","received_avp", "$avp(i:42)")
    modparam("nathelper","received_avp", "$avp(i:42)")

    modparam("avpops","db_url","mysql://opensips:opensipsrw@localhost/opensips")

    modparam("usrloc", "db_mode", 2)
    modparam("usrloc", "db_url","mysql://opensips:opensipsrw@localhost/opensips")
    modparam("usrloc", "nat_bflag", 6)

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

    modparam("rr", "enable_full_lr", 1)
    modparam("rr", "append_fromtag", 0)

    modparam("acc", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
    modparam("acc", "db_extra", "caller_id=$fu; callee_id=$tu")
    modparam("acc", "early_media", 1)
    modparam("acc", "report_ack", 1)
    modparam("acc", "report_cancels", 1)
    modparam("acc", "detect_direction", 0)
    modparam("acc", "failed_transaction_flag", 3)
    modparam("acc", "log_flag", 1)
    modparam("acc", "log_missed_flag", 2)
    modparam("acc", "db_flag", 1)
    modparam("acc", "db_missed_flag", 2)

    modparam("load_balancer", "db_url","mysql://opensips:opensipsrw@localhost/opensips")
    modparam("load_balancer", "probing_interval", 60)
    modparam("load_balancer", "probing_from", "sip:184556000@127.0.0.1")
    modparam("load_balancer", "probing_reply_codes", "501, 403, 404")

    modparam("dialog", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")
    modparam("dialog", "dlg_flag", 13)
    modparam("dialog", "db_mode", 3)

    modparam("auth_db", "calculate_ha1", yes)
    modparam("auth_db", "password_column", "password")
    modparam("auth_db", "db_url","mysql://opensips:opensipsrw@localhost/opensips")
    modparam("auth_db", "load_credentials", "")

    route{

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

    # NAT detection
       route(2);

       if (has_totag() ) {
         loose_route();
         t_relay();
         exit;
       }

    if (is_method("CANCEL")) {
                  if (t_check_trans())
                  t_relay();
                  exit;
    }

    if (!is_method("INVITE") && !is_method("REGISTER")) {
            send_reply("405", "Method Not Allowed");
            exit;
    }

        if (is_method("INVITE")) {
                   record_route();
        }

        t_check_trans();

        if (!(method=="REGISTER") && from_uri==myself){

         if (!proxy_authorize("", "subscriber")) {
         proxy_challenge("", "0");
         exit;
         }

         if (!db_check_from()) {
         sl_send_reply("403","Forbidden auth ID");
         exit;
         }
       
         consume_credentials();
        }

        if (is_method("REGISTER")){
           if (!www_authorize("", "subscriber")){          
                    switch ($retcode) {
                        case -5:
                            xlog("L_INFO","Error");
                            break;
                        case - 4:
                            xlog("L_INFO", "Please send new Register with auth info $fU");
                            www_challenge("", "0");
                            exit;
                        case - 2:
                            xlog("L_INFO", "Wrong password for user $fU");
                            sl_send_reply("401", "Wrong password");
                            break;
                        case - 1:
                            xlog("L_INFO", "User doesnt exist $fU");
                            sl_send_reply("401", "User doesnt exist");
                            break;
                    }
               www_challenge("", "0");
               exit;
              }
           if (!db_check_to()){
              sl_send_reply("403","Forbidden auth ID");
              exit;
            }
          
            if (!save("location")){
              sl_reply_error();
              exit;
             } else{
              xlog("L_NOTICE", "User is register $fU");
            }

       if ($rU==NULL) {
           sl_send_reply("484","Address Incomplete");
           exit;
        }

    exit;
    }

        #xlog("URI=$ru nunbercallerd=$rU td=$td tn=$tn si=$si fU=$fU");
       
        avp_db_query("SELECT username FROM subscriber WHERE username='$rU'");
        
        if($avp(i:1) > '0'){     
            xlog("L_NOTICE", "Call send for user $avp(i:1)");
            if (!lookup("location", "m")) {
            }
            route(1);
        } else {
            xlog("L_NOTICE", "Call send for load balance");
            route(4);
        }

    exit;
    }

    #rout for user only

    route {

    if (is_method("BYE|CANCEL")) {
         unforce_rtp_proxy();
    }else if (is_method("INVITE")) {
                if(has_body("application/sdp")){
                    xlog ("Setting rtpproxy_offer - Route 1 user $fU");
                    if ( !rtpproxy_offer("rc","209.190.36.146") )
                            xlog ("==== rtpproxy problem - $rc");
                    else
                            xlog ("==== rtpproxy ok");
                    t_on_reply("1");
                }else{
                    t_on_reply("2");
                }
        t_on_failure("1");
        }
        if (!t_relay()) {
            sl_reply_error();
        }
       
        exit;
    }

    route{
       force_rport();
       if (nat_uac_test("19")) {
          if (method=="REGISTER") {
             xlog ("fix_nated_register user $fU");
             fix_nated_register();
          } else {
             xlog ("fix_nated_contact user $fU");
             fix_nated_contact();
          };
          setflag(5);
       }
    }

    onreply_route
    {

        if (has_body("application/sdp"))
            rtpproxy_answer();

        if (isbflagset(6))
        {
            search_append('Contact:.*sip:[^>]*', ';nty=yes');
            search_append('m:.<sip:[^>]*', ';nty=yes');
           
        }
        exit;
    }

    onreply_route
    {
        if (has_body("application/sdp"))
            rtpproxy_offer();
           
        if (isbflagset(6))
        {
            search_append('Contact:.*sip:]*', ';nty=yes');
            search_append('m:.<sip:[^>]*', ';nty=yes');
          
        }
        exit;
    }

    failure_route {
             if (isflagset(5) || isbflagset(6)){
              unforce_rtp_proxy();
           }
    if (t_was_cancelled()) {
    exit;
    }
         
    if (t_check_status("486|408|407")) {
                   xlog ("voicemail");
                   route(4);              
    exit;
    }
    }

    route {
        if ($td == "209.190.36.146") {
                load_balance("1", "pstn");
        } else {
                sl_send_reply("500", "Service is full");
                exit;
        }
                if ($retcode < 0) {
                    sl_send_reply("500", "Service full");
                    exit;
                }
       xlog("Selected destination is: $du for number: $rU  user: $fU\n");
       t_relay();
      
    exit;
    }

     
  • It does not work like this - "check my cfg" - if you have a particular problem, explain it in details and maybe we will able to help. Keep in mind that "my NAT traversal does not work" is not a problem - go to the bottom of it like "I have one way audio", "calls are not establishing", etc

    Bogdan

     
  • monica
    monica
    2011-09-14

    Some calls are disconnected, I believe that the order of the functions, record_route(), are wrong.

     
  • monica
    monica
    2011-09-14

    another problem. calls between users, I  call user-agent: eyeBeam for user-agent: Linksys PAP2.

    error "callFailed: Media negotiation failed"

    the two users with codec g729

    tanks