i used kamailio v4.1  

part of  kamailio.cfg 
for examples:

disable_tcp=no
auto_aliases=no

port=5085
enable_tls=yes
listen=udp:10.2.45.111:5085
listen=tcp:10.2.45.111:5085
listen=tls:10.2.45.111:5086
listen=tcp:10.2.45.111:5087
listen=tls:10.2.45.111:5088

and i excute
/etc/init.d/kamailio start
it can run

but when on ka v4.4.0 
the same contents in kamailio.cfg but can`t run 

both 4.1.x and 4.4.x when i change 
disable_tcp=yes 
it can run
but only listen on udp 5085 

v4.1 i change disable_tcp=no 
it can listen tls,tcp.udp

i use modules: dispatcher 
v4.4 i setup a new modules : evapi 

why tcp can`t run properly?


`#!KAMAILIO




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

debug=0
log_stderror=no

memdbg=5
memlog=5

log_facility=LOG_LOCAL1
fork=yes
children=5
tcp_children=4

#disable_tcp=no

auto_aliases=no

port=5085

#4.1
enable_tls=yes


listen=udp:10.2.45.111:5085
listen=tcp:10.2.45.111:5085
listen=tls:10.2.45.111:5086
listen=tcp:10.2.45.111:5087
listen=tls:10.2.45.111:5088


sip_warning=no


#4.1
tcp_accept_no_cl=yes
tcp_connection_lifetime=3604
tcp_rd_buf_size=16384
exit_timeout = 300
#4.1

mpath="/home/administrator/kamailio/modules_k/:/home/administrator/kamailio_proxy/lib64/kamailio/modules/"


loadmodule "db_mysql.so"
loadmodule "mi_fifo.so"
loadmodule "kex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "mi_rpc.so"
loadmodule "acc.so"
loadmodule "dispatcher.so"


#4.1
loadmodule "tls.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "xhttp.so"
loadmodule "websocket.so"
loadmodule "usrloc.so"
loadmodule "nathelper.so"
loadmodule "registrar.so"
#4.1

#added by liqixin
#loadmodule "evapi.so"
#added by liqixin

# ----------------- setting module-specific parameters ---------------


# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")


# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)


# ----- acc params -----
modparam("acc", "log_flag", 1)
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_extra", 
        
"src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;src_ip=$si")

# ----- tm params -----
modparam("tm", "fr_timer", 2000)
modparam("tm", "fr_inv_timer", 40000)

# ----- dispatcher params -----

modparam("dispatcher", "db_url", 
"mysql://kamailio:kamailiorw@localhost/kamailio")
modparam("dispatcher", "table_name", "dispatcher")
modparam("dispatcher", "flags", 2)
modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")
modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)")
modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)")

#4.4
modparam("dispatcher", "sock_avp", "$avp(AVP_SOCK)")
#4.4

#4.1
modparam("dispatcher", "ds_ping_method", "OPTIONS")
modparam("dispatcher", "ds_ping_from", "sip:[email protected]")
modparam("dispatcher", "ds_ping_interval", 10)
modparam("dispatcher", "ds_probing_threshold", 3)
modparam("dispatcher", "ds_ping_reply_codes", "class=2;code=400;class=3")
modparam("dispatcher", "ds_probing_mode", 1)
#4.1

#4.1
# ----- usrloc params -----
/* enable DB persistency for location entries */
modparam("usrloc", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio")
modparam("usrloc", "db_mode", 0)

modparam("registrar", "method_filtering", 1)
modparam("registrar", "max_expires", 3600)
modparam("registrar", "gruu_enabled", 0)
modparam("registrar", "use_path", 1) 
modparam("registrar", "path_mode", 1) 
modparam("registrar", "path_use_received", 0)
modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
modparam("usrloc", "nat_bflag", 6)
#4.1

#4.1

# ----- tls params -----
#modparam("websocket", "cors_mode", 0);
modparam("websocket", "keepalive_mechanism", 0);

# ----- tls params -----
modparam("tls", "config", 
"/home/administrator/kamailio_proxy/etc/kamailio/tls.cfg")

#4.1

#-------evapi----------
#modparam("evapi", "workers", 2)
#modparam("evapi", "bind_addr", "10.2.45.111:5085")
 

####### Routing Logic ########


# main request routing logic

route {


        route(REQINIT);
    
    #4.1
    if (nat_uac_test(64)) {
                # Do NAT traversal stuff for requests from a WebSocket
                # connection - even if it is not behind a NAT!
                # This won't be needed in the future if Kamailio and the
                # WebSocket client support Outbound and Path.
                force_rport();
                        fix_nated_register();
                        add_contact_alias();
        }       
        

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


        route(WITHINDLG);


#4.4

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

#4.4

        t_check_trans();

#4.4
#       remove_hf("Route");

#       if (is_method("INVITE|SUBSCRIBE"))
#               record_route();


#       if (is_method("INVITE"))
#       {
#               setflag(1); # do accounting
#       }


#       route(PRESENCE);


#       route(REGISTRAR);

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

        route(DISPATCH);


#4.1
    route(RELAY);
#4.1

}

#4.1 xlog 
route[RELAY] {
        if (!t_relay()) {
                sl_reply_error();
        }
        exit;
}
#---4.1---


# Per SIP request initial checks
route[REQINIT] {
        #4.4
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        }
    #4.4

        if(!sanity_check("1511", "7"))
        {
                xlog("Malformed SIP message from $si:$sp\n");
                exit;
        }
}

# Handle requests within SIP dialogs
route[WITHINDLG] {
        if (has_totag()) {
        
                if (loose_route()) {

                        if (is_method("BYE")) {
                                setflag(1); # do accounting ...
                                setflag(3); # ... even if the transaction fails
                        }

                        #4.1 
             #   if ($du == "") {
                         #      handle_ruri_alias();
             #           }
                        #4.1


                        route(RELAY);
                } else {

                #4.4
                        if (is_method("SUBSCRIBE") && uri == myself) {
                                # in-dialog subscribe requests
                                route(PRESENCE);
                                exit;
                        }
                #4.4


                        if ( is_method("ACK") ) {
                                if ( t_check_trans() ) {

                                        t_relay();
                                        exit;
                                } else {

                                        exit;
                                }
                        }
                        sl_send_reply("404","Not here");

        #4.1    if ( is_method("ACK") ) {
                #               if ( t_check_trans() ) {

                #                       t_relay();
                #                       exit;
                #               } else {
                                        
                #                       exit;
                #               }
                #       }
                 #   sl_send_reply("404","Not here");

                }

                #4.1 route(RELAY);
                exit;
        }
}




# Handle SIP registrations 4.4
route[REGISTRAR] {
        if(!is_method("REGISTER"))
                return;
        sl_send_reply("404", "No registrar");
        exit;
}

# Presence server route 4.4
route[PRESENCE] {
        if(!is_method("PUBLISH|SUBSCRIBE"))
                return;

        sl_send_reply("404", "Not here");
        exit;
}



# Dispatch requests-------4.4
# route[DISPATCH] {
        # round robin dispatching on gateways group '1'
#       if(!ds_select_dst("1", "4"))
#       {
#               send_reply("404", "No destination");
#               exit;
#       }
#       xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");
#       t_on_failure("RTF_DISPATCH");
#       route(RELAY);
#       exit;
#   }
# Dispatch requests-------4.4

#4.1----------------dispatch
# Dispatch requests
route[DISPATCH] {
        # round robin dispatching on gateways group '1'
        if(is_method("REGISTER")){
                if(ds_select_dst("1", "0"))
                {
                        loose_route();
                #       route(RELAY);
                }
                else
                {
                        send_reply("404", "No destination");
                        exit;
                }
        }

        else if (is_method("INVITE")) {
                        if ($du == "") {
                                if (!handle_ruri_alias()) {
                                        xlog("L_ERR", "Bad alias <$ru>\n");
                                        sl_send_reply("400", "Bad Request");
                                        exit;
                                }
                        }


                
                $avp(route)=$(hdr(Route)[0]);
                $avp(LastRouteParam)=$(avp(route){param.count})-1;
                if($(avp(route){param.name,$avp(LastRouteParam)})=="fccs>"){    
                        #xlog("the method invite from sipserver \n");
                        loose_route();
                        if( $(ru{param.value,transport}) == 
"TCP"||$(ru{param.value,transport}) == "tcp" ){
                                
record_route_preset("10.2.45.111:5085;transport=tcp","10.2.45.111:5085");
                        }
                        else if( $(ru{param.value,transport}) == 
"TLS"||$(ru{param.value,transport}) == "tls" ){        
                               
record_route_preset("10.2.45.111:5086;transport=tls","10.2.45.111:5085");
                         }
                        else if( $(ru{param.value,transport}) == 
"WS"||$(ru{param.value,transport}) == "ws" ){
                                
record_route_preset("10.2.45.111:5087;transport=ws","10.2.45.111:5085");
                         }
                        else if( $(ru{param.value,transport}) == 
"WSS"||$(ru{param.value,transport}) == "ws" ){
                                
record_route_preset("10.2.45.111:5088;transport=wss","10.2.45.111:5085");       
                  

                        }
                        else{
                                
record_route_preset("10.2.45.111:5085","10.2.45.111:5085");
                        }

                        route(RELAY);   
                }
                
                else{
                        if (ds_select_dst("1", "6")) {
                                #xlog("the first invite load balance \n");
                                if(proto==TCP){
                                        
record_route_preset("10.2.45.111:5085","10.2.45.111:5085;transport=tcp");
                                }
                                else if(proto==TLS){
                                      
record_route_preset("10.2.45.111:5085","10.2.45.111:5086;transport=tls");
                                }
                                else if(proto==WS){
                                        
record_route_preset("10.2.45.111:5085","10.2.45.111:5087;transport=ws");
                                }
                                else if(proto==WSS){
                                        
record_route_preset("10.2.45.111:5085","10.2.45.111:5088;transport=wss");
                                }


                                else{
                                        
record_route_preset("10.2.45.111:5085","10.2.45.111:5085");
                                        }
                                loose_route();  
                                route(RELAY);
                        }
                
                        else{
                                send_reply("503","Invite Load_balance Service 
Unavailable");
                        exit;

                        }
                }
       }

        else 
if(is_method("MESSAGE")||is_method("REFER")||is_method("PUBLISH")||is_method("SUBSCRIBE")||is_method("NOTIFY")){
                 $avp(route2)=$(hdr(Route)[0]);
                $avp(LastRouteParam2)=$(avp(route){param.count})-1;

                if($(avp(route2){param.name,$avp(LastRouteParam2)})=="fccs>"){
                        loose_route();
                        route(RELAY);

                }
                else{
                         if(ds_select_dst("1", "0"))
                         {
                                   loose_route();
                                 # route(RELAY);
                         }
        
                        else
                         {
                                 send_reply("404", "No destination");
                                  exit;
                         }
                }
        }

        else{
                send_reply("400","method not defined \n");
        }

        xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");
        t_on_failure("RTF_DISPATCH");
        return;                 

}

#----------------4.1 dispatch


# Sample failure route ----4.4
#failure_route[RTF_DISPATCH] {
#       if (t_is_canceled()) {
#               exit;
#       }
        # next DST - only for 500 or local timeout
#       if (t_check_status("500")
#                       or (t_branch_timeout() and !t_branch_replied()))
#       {
#               if(ds_next_dst())
#               {
#                       t_on_failure("RTF_DISPATCH");
#                       route(RELAY);
#                       exit;
#               }
#       }
#    }

# Sample failure route ----4.4

# Sample failure route
failure_route[RTF_DISPATCH] {
        if (t_is_canceled()) {
                exit;
        }
        # next DST - only for 500 or local timeout
        if (t_check_status("500")
                        or (t_branch_timeout() and !t_branch_replied()))
        {
                if(ds_next_dst())
                {
                        t_on_failure("RTF_DISPATCH");
                        route(RELAY);
                        exit;
                }
                #4.1
                ds_mark_dst("ip"); # set to inactive and probing
                #4.1
        }
}


#4.1
onreply_route {
        if (nat_uac_test(64)) {
                # Do NAT traversal stuff for replies to a WebSocket connection
                # - even if it is not behind a NAT!
                # This won't be needed in the future if Kamailio and the
                # WebSocket client support Outbound and Path.
                add_contact_alias();
        }
}
#4.1



event_route[xhttp:request] {
        set_reply_close();
        set_reply_no_connect();
        #set_forward_close();
        #set_forward_no_connect();
        #t_relay();
        if ($Rp != 5087 && $Rp != 5088) 
        {
                xlog("L_WARN", "HTTP request received on $Rp\n");
                xhttp_reply("403", "Forbidden", "", "");
                exit;
        }
 
        xlog("L_DBG", "HTTP Request Received\n");
 
        if ($hdr(Upgrade)=~"websocket"
                        && $hdr(Connection)=~"Upgrade"
                        && $rm=~"GET") {
                #xlog("websocket upgrade ok\n"); 
                # Validate Host - make sure the client is using the correct
                # alias for WebSockets
                if ($hdr(Host) == $null || !is_myself("sip:" + $hdr(Host))) {
                        xlog("L_WARN", "Bad host $hdr(Host)\n");
                        xhttp_reply("403", "Forbidden", "", "");
                        exit;
                }
 
                # Optional... validate Origin - make sure the client is from an
                # authorised website.  For example,
                #
                # if ($hdr(Origin) != "http://communicator.MY_DOMAIN";
                #     && $hdr(Origin) != "https://communicator.MY_DOMAIN";) {
                #       xlog("L_WARN", "Unauthorised client $hdr(Origin)\n");
                #       xhttp_reply("403", "Forbidden", "", "");
                #       exit;
                # }
 
                # Optional... perform HTTP authentication
 
                # ws_handle_handshake() exits (no further configuration file
                # processing of the request) when complete.
                if (ws_handle_handshake())
                {
                        # Optional... cache some information about the
                        # successful connection

                        exit;
                }

        }
        #route(RELAY);
        xhttp_reply("404", "Http Not Found", "", "");
}



event_route[websocket:closed] {
        xlog("L_INFO", "WebSocket connection from $si:$sp has closed\n");
}

#added by liqixin
#event_route[evapi:connection-new] {
#   xlog("new connection from $evapi(srcaddr):$evapi(srcport)\n");
#}

#event_route[evapi:connection-closed] {
#    xlog("connection closed by $evapi(srcaddr):$evapi(srcport)\n");
#}
#added by liqixin`


---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/585
_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to