OpenSIPS / opensips

OpenSIPS is a GPL implementation of a multi-functionality SIP Server that targets to deliver a high-level technical solution (performance, security and quality) to be used in professional SIP server platforms.
https://opensips.org
Other
1.27k stars 578 forks source link

use OpenSips as SIP PROXY, have some problems when call #3101

Closed jiangxc closed 1 year ago

jiangxc commented 1 year ago

phone ------> OpenSips -----------> Asterisk(20.2.1)(use PJSIP) OpenSips Version:Server:: OpenSIPS (2.4.11 (x86_64/linux))

opensips:192.168.0.138 asterisk:192.168.0.218

OpenSips run in cloud,register and call success,but there was no sound!Call directly using Asterisk is ok. Is there a problem with the configuration?

looking forward to waiting for the reply ~~

opensips.cfg

log_level=3
sip_warning=0
log_stderror=no
log_facility=LOG_LOCAL0
#log_name="opensips"
debug_mode=no
children=4
dns_try_ipv6=no
auto_aliases=no
listen=udp:192.168.0.138:5565 as 36.104.147.190:5565
advertised_address="36.104.147.190"
advertised_port=5565
alias="36.104.147.190"
mpath="/usr/local//lib64/opensips/modules/"
db_default_url="mysql://opensips:opensips.pwd@dbserver:3306/opensips"

loadmodule "db_mysql.so"
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "uri.so"
loadmodule "dialog.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
loadmodule "dispatcher.so"
loadmodule "load_balancer.so"
loadmodule "sipmsgops.so"
loadmodule "proto_udp.so"
loadmodule "path.so"
loadmodule "cachedb_local.so"
loadmodule "usrloc.so"
modparam("usrloc", "nat_bflag", "NAT")
modparam("usrloc", "db_mode",   2)
loadmodule "nathelper.so"
modparam("nathelper", "natping_interval", 10)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", "SIP_PING_FLAG")
modparam("nathelper", "sipping_from", "sip:pinger@127.0.0.1") #CUSTOMIZE ME
modparam("nathelper", "received_avp", "$avp(received_nh)")
loadmodule "nat_traversal.so"
loadmodule "uac_redirect.so"

modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
modparam("dialog", "db_mode", 1)
#modparam("dialog", "db_url", "mysql://opensips:opensips.pwd@dbserver:3306/opensips") 
modparam("rr", "enable_double_rr", 1)
modparam("rr", "append_fromtag", 1)
modparam("tm", "fr_timer", 2)

#modparam("dispatcher", "db_url", "mysql://opensips:opensips.pwd@dbserver:3306/opensips")
modparam("dispatcher", "ds_ping_method", "OPTIONS")
modparam("dispatcher", "ds_ping_interval", 5)
modparam("dispatcher", "ds_probing_threshhold", 2)
modparam("dispatcher", "ds_probing_mode", 1)

#modparam("load_balancer", "db_url", "mysql://opensips:opensips.pwd@dbserver:3306/opensips")
modparam("load_balancer", "probing_method", "OPTIONS")
modparam("load_balancer", "probing_interval", 5)

loadmodule "rtpproxy.so"
modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7890") # CUSTOMIZE ME

route{ 
    force_rport();

    if (nat_uac_test("23")) {
        if (is_method("REGISTER")) {
            fix_nated_register();
            setbflag(NAT);
        }else {
            fix_nated_contact();
            setflag(NAT);
        }
    }

    if (!mf_process_maxfwd_header("10")) {
        sl_send_reply("483","Too Many Hops");
        exit;
    }  

    if (has_totag()) {
        # sequential request withing a dialog should
        # take the path determined by record-routing
        if (loose_route()) {             
               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(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");
        }
        if (check_route_param("nat=yes")) 
            setflag(NAT);
        exit;
    } 

    if (ds_is_in_list("$si", "", "1"))
    {
        route(relay);
        exit;
    } 

    # check if the clients are using WebSockets or WebSocketSecure

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

    t_check_trans();

     # If the request is a register we will pass it along but we need
    # to add the path header (along with the received IP/port info)
    if ( is_method("REGISTER"))
    { 
        if(isflagset(SRC_WS)){
            # if we fail to add the path header then dont let it
            # register because it will cause issues later..
            if (!add_path_received())
            {
                xlog("L_ERR", "$ci|log|unable to add path");

                sl_send_reply("503", "Internal path befuddlement");

                xlog("L_INFO", "$ci|end|cleaned up call id from cache");

                exit;
            }
            xlog("L_INFO", "$ci|log|added path");
        }

        if (isflagset(SRC_WS)){
            fix_nated_register();
            setbflag(DST_WS);
        } 
    }

    # 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();

    if (!is_myself("$rd")) {
        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 (!ds_select_dst("1", "0")) {
                send_reply("503","Service Unavailable");
                exit;
        } 
        if (isflagset(NAT)) {
            setbflag(SIP_PING_FLAG);
        }

    }
    else if (is_method("INVITE")) {
        if (!load_balance("1","pstn")) {
            send_reply("503","Service Unavailable");
            exit;
        }

    } 
    if (isbflagset(NAT)) setflag(NAT);        
    route(relay);
}

route[relay] {

    if (is_method("INVITE")) {
        if (isflagset(NAT)) {
            rtpproxy_offer("ro");
        }
        t_on_branch("per_branch_ops");
        t_on_reply("handle_nat");
        t_on_failure("missed_call");
    }
    if (isflagset(NAT)) {
        add_rr_param(";nat=yes");
    }
    if (!t_relay()) {
        send_reply("500","Internal Error");
    };
    exit;
}

branch_route[per_branch_ops] {
    xlog("new branch at $ru\n");
}

onreply_route[handle_nat] { 
    if (nat_uac_test("1"))
        fix_nated_contact();
    if ( isflagset(NAT) && has_body("application/sdp"))
        rtpproxy_answer("ro");
    xlog("incoming reply\n");
}

failure_route[missed_call] {
    if (t_was_cancelled()) {
        exit;
    } 
}

local_route 
{    
     if (is_method("BYE") ) 
     {
        # acc_log_request("internally generated BYE");
     }
}

opensipsctl fifo ds_list

PARTITION:: default
    SET:: 1
        URI:: sip:192.168.0.218:5567 state=Active first_hit_counter=0
            attr:: a1

opensipsctl fifo lb_list

Destination:: sip:192.168.0.218:5567 id=1 group=1 enabled=yes auto-reenable=on
    Resources:: 
        Resource:: pstn max=3000 load=0

Thanks.

github-actions[bot] commented 1 year ago

Any updates here? No progress has been made in the last 15 days, marking as stale. Will close this issue if no further updates are made in the next 30 days.

bogdan-iancu commented 1 year ago

This tracker is intended for code related issue, not for configuration issues. For that, please use http://lists.opensips.org/cgi-bin/mailman/listinfo/users