[OpenSIPS-Users] Hung dialogs

Duane Larson duane.larson at gmail.com
Thu Nov 3 22:48:39 CET 2011


You want to trade concurrent call scripts?  I have one to and sometimes run
into issues where it thinks there is an existing call for a user so it
sends a reached max calls limit.




On Thu, Nov 3, 2011 at 3:36 PM, Ryan Revels <ryan at revelous.net> wrote:

> I've run into an issue where *very* rarely, dialogs will "hang", that is,
> the dialog will continue to exist even though the call never connected. In
> the example I managed to track down, the proxy should reject the call
> (because a limit of concurrent calls has been reached) and at first, it
> seems like it's going to... but then it sends a 100 Trying and continues to
> route the call to the destination. From there, everything spirals and the
> dialog doesn't die until it hits the global timeout.
>
> The relevant portion of my script looks like:
>
> # Check gateway calls total
> if ($avp(custgwtotal_limit) != "0" && $avp(custgwtotal_limit) != NULL &&
> $avp(custgwtotal_limit) != "")
> {
>    get_profile_size("custgwtotal","$rd","$avp(custgwtotal_count)");
>    if (!$avp(custgwtotal_count) < $avp(custgwtotal_limit))
>    {
>       sl_send_reply("486","Endpoint Session Limit");
>       exit;
>    }
> }
> set_dlg_profile("custgwtotal","$rd"); #count total calls to customer's IP
>
> I've attached a pcap example of what the signaling looks like when the
> dialog hangs. For this example, the output in dlg_list looks like:
>
> dialog::  hash=629:349156783
> state:: 3
>  user_flags:: 0
> timestart:: 1320336333
>  timeout:: 1320357957
> callid:: did2.139.1120741
>  from_uri:: sip:16034299966 at 64.136.174.30
>  to_uri:: sip:16038869119 at 184.106.218.8
>  caller_tag:: 1ae26ee84c61df6b84baef371d2bf5e4
> caller_contact:: sip:184.106.219.203:5060;transport=udp
>  callee_cseq:: 0
> caller_route_set::
>  caller_bind_addr:: udp:184.106.218.8:5060
>  callee_tag:: as58f4e19a
> callee_contact:: sip:16038869119 at 71.168.70.47
>  caller_cseq:: 2
> callee_route_set::
>  callee_bind_addr:: udp:184.106.218.8:5060
>
> Any help would be appreciated.
>
> Thanks,
> Ryan
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>


-- 
--
*--*--*--*--*--*
Duane
*--*--*--*--*--*
--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20111103/3e58ef1a/attachment-0001.htm>
-------------- next part --------------
route[ConcurrentCallLimiter]
{

xlog("L_INFO", "Route ConCurrentCall: Call [$rm] du [$du] rd [$rd] td [$td] ds [$ds] Ri [$Ri] rU[$rU] fU[$fU] ru[$ru] fu[$fu] tu[$tu] od[$od] fd[$fd]\n");


        ## have we done our checking on this call?
        if(!isflagset(31) && $hdr(User-Agent)!~ "ipcom.at")
        {

                #This will keep up with concurrent calls for Caller (fu)
                #The td != aethercommunications is to keep the internal callee from having double concurrent calls due to a hunt group call
                #If this wasn't here then if 333 at irock.com called huntgroup1 at irock.com and 444 was the callee from huntgroup then he
                #would be considered the caller and callee because of the SIP INVITE coming from the asterisk server
                if(avp_db_load("$fu/username", "$avp(channels)") && $td != "aethercommunications.com" ) {

                        # user has max channel limit set as preference
                        if(is_avp_set("$avp(channels)/n") && avp_check("$avp(channels)", "gt/i:0"))
                        {
                                # get current calls for uuid
                                get_profile_size("ConcurrentCalls","$fU","$var(CallerCalls)");

                                # check within limit
                                if($avp(channels) > $var(CallerCalls))
                                {
                                        xlog("L_INFO", "Call control: Caller '$fU' currently has '$var(CallerCalls)' of '$avp(channels)' active calls before this one\n");
                                        $var(setprofileCaller) = 1;
                                }
                                else
                                {
                                        xlog("L_INFO", "Call control: Caller channel limit exceeded [$var(CallerCalls)/$avp(channels)]\n");
                                        sl_send_reply("487","Request Terminated: Channel limit exceeded");
                                        exit;
                                }
                        }
                        else
                        {
                                $var(setprofileCaller) = 0;
                        }



                        if($var(setprofileCaller) > 0)
                        {
                                if ( !match_dialog() )
                                {
                                        create_dialog();
                                }
                                set_dlg_profile("ConcurrentCalls","$fU");
                                get_profile_size("ConcurrentCalls","$fU","$var(CallerCalls)");
                                xlog("L_INFO", "Call control: Caller '$fU' now has '$var(CallerCalls)' of '$avp(channels)' active calls\n");
                        }
                }




                #This will keep up with concurrent calls for Callee (ru)
                #if(is_domain_local("$rd")) {
                if(avp_db_load("$ru/username", "$avp(channels)") ) {        

                        # user has max channel limit set as preference
                        if(is_avp_set("$avp(channels)/n") && avp_check("$avp(channels)", "gt/i:0"))
                        {
                                # get current calls for uuid
                                get_profile_size("ConcurrentCalls","$rU","$var(CalleeCalls)");                

                                # check within limit
                                if($avp(channels) > $var(CalleeCalls))
                                {
                                        xlog("L_INFO", "Call control: Callee '$rU' currently has '$var(CalleeCalls)' of '$avp(channels)' active calls before this one\n");                
                                        $var(setprofileCallee) = 1;
                                }                
                                else             
                                {
                                        xlog("L_INFO", "Call control: user channel limit exceeded [$var(CalleeCalls)/$avp(channels)]\n");

                                        route(MEDIASERVER);

                                }
                        }
                        else
                        {
                                $var(setprofileCallee) = 0;
                        }              



                        if($var(setprofileCallee) > 0) 
                        {
                                if ( !match_dialog() )
                                {
                                        create_dialog();
                                }
                                set_dlg_profile("ConcurrentCalls","$rU");
                                get_profile_size("ConcurrentCalls","$rU","$var(CalleeCalls)");                
                                xlog("L_INFO", "Call control: Callee '$rU' now has '$var(CalleeCalls)' of '$avp(channels)' active calls\n");
                        }

                }




                #We need to set restrictions on how many calls a Customer can have
                #go out to the PSTN or other customers
                #
                #Each customer has an AVPOP called LANSite that tells us if the domain users are 
                #located behind the same WAN router or not.  So if the Caller and Callee's LANSite
                #AVPOP doesn't equal each other then that means the RTP traffic is going to traverse
                #the WAN router

                avp_db_load("$ru/username", "$avp(LANSite)");
                        if($avp(LANSite) != null)
                        {
                                $var(ToLANSite) = $avp(LANSite);
                        }
                avp_db_load("$fu/username", "$avp(LANSite)");
                        if($avp(LANSite) != null)
                        {
                                $var(FromLANSite) = $avp(LANSite);
                        }

                xlog("L_INFO", "Call Control: Before IF statement ToLANSite [$var(ToLANSite)] FromLANSite [$var(FromLANSite)] \n");


                #We need to check and make sure the To and From DID are not the same.  If they are then
                #that means it is a Hunt Group Call from an internal user to their companies own huntgroup
                #We don't want to consider that a WAN Call even though it could be possible it is if the customer
                #has multiple remote sites.  But there is no way to tell if the two internal users are at two different locations
                if( $rU != $fU) {

                if( ($var(ToLANSite) != $var(FromLANSite)) || ( $si != $dd || $dd==null) || $rU == $fU) {
                        xlog("L_INFO", "Call control: ru [$ru] and fu [$fu] \n");
                        xlog("L_INFO", "Call control: si [$si] and dd [$dd] \n");
                        xlog("L_INFO", "Call control: rd [$rd] and fd [$fd] \n");
                        xlog("L_INFO", "Call control: ToLANSite [$var(ToLANSite)] and FromLANSite [$var(FromLANSite)] \n");


                        if(is_domain_local("$fd")) {
                                #This will keep up with concurrent calls for the whole domain
                                #This is a customer calling Out to PSTN or another customer
                                avp_db_load("$fu/domain", "$avp(channels)");

                                # Domain has max channel limit set as preference
                                if(is_avp_set("$avp(channels)/n") && avp_check("$avp(channels)", "gt/i:0"))
                                {
                                        # get current calls for From Domain fd
                                        get_profile_size("ConcurrentCalls","$fd","$var(DomainCallerCalls)");

                                        # check within limit
                                        if($avp(channels) > $var(DomainCallerCalls))
                                        {
                                                xlog("L_INFO", "Call control: Domain '$fd' currently has '$var(DomainCallerCalls)' of '$avp(channels)' active calls before this one\n");
                                                $var(setprofileDomainCaller) = 1;
                                        }
                                        else
                                        {
                                                xlog("L_INFO", "Call control: user channel limit exceeded [$var(DomainCallerCalls)/$avp(channels)]\n");
                                                sl_send_reply("487","Request Terminated: Channel limit exceeded");
                                                exit;
                                        }
                                }
                                else
                                {
                                        $var(setprofileDomainCaller) = 0;
                                }



                                if($var(setprofileDomainCaller) > 0)
                                {
                                        if ( !match_dialog() )
                                        {
                                                create_dialog();
                                        }
                                        set_dlg_profile("ConcurrentCalls","$fd");
                                        get_profile_size("ConcurrentCalls","$fd","$var(DomainCallerCalls)");
                                        xlog("L_INFO", "Call control: Domain '$fd' now has '$var(DomainCallerCalls)' of '$avp(channels)' active calls\n");
                                }

                        }

                        # We have to use $var(callee_domain) because if the callee is a customer then when we did the lookup("location") function in route(10)
                        # the domain part got changed from the actual domain (ex. irock.com) to the actual public IP address that is in the location database.
                        # At the very beginning of Route(10) we set $var(callee_domain) = $rd so we are good with using it here.

                        if(is_domain_local("$var(callee_domain)") && $rd!="sip22.vitelity.net") {
                                #This will keep up with concurrent calls for the whole domain
                                #This is a customer being called by PSTN or another customer
                                avp_db_load("$ru/domain", "$avp(channels)");

                                # user has max channel limit set as preference
                                if(is_avp_set("$avp(channels)/n") && avp_check("$avp(channels)", "gt/i:0"))
                                {
                                        # get current calls for uuid
                                        get_profile_size("ConcurrentCalls","$var(callee_domain)","$var(DomainCalleeCalls)");

                                        # check within limit
                                        if($avp(channels) > $var(DomainCalleeCalls))
                                        {
                                                xlog("L_INFO", "Call control: Domain '$var(callee_domain)' currently has '$var(DomainCalleeCalls)' of '$avp(channels)' active calls before this one\n");
                                                $var(setprofileDomainCallee) = 1;
                                        }
                                        else
                                        {
                                                xlog("L_INFO", "Call control: user channel limit exceeded [$var(DomainCalleeCalls)/$avp(channels)]\n");

                                                route(MEDIASERVER);               

                                        }
                                }
                                else
                                {
                                        $var(setprofileDomainCallee) = 0;
                                }



                                if($var(setprofileDomainCallee) > 0)
                                {
                                        if ( !match_dialog() )
                                        {
                                                create_dialog();
                                        }
                                        set_dlg_profile("ConcurrentCalls","$var(callee_domain)");
                                        get_profile_size("ConcurrentCalls","$var(callee_domain)","$var(DomainCalleeCalls)");
                                        xlog("L_INFO", "Call control: Domain var(callee)[$var(callee_domain)] td[$td] now has '$var(DomainCalleeCalls)' of '$avp(channels)' active calls\n");
                                }

                        }

                }

                }

                #Cleanup AVPs
                avp_delete("$avp(LANSite)");
                avp_delete("$avp(channels)");

                ## mark checking done
                setflag(31);
        }
}


More information about the Users mailing list