[OpenSIPS-Users] Possibilities to handle short duration calls using new capabilities in opensips 3.1

Jon Abrams ffshoh at gmail.com
Thu Jun 25 17:44:01 EST 2020


This is what my snippets look like. I save the actual receive time for
the BYE for accounting purposes, as the CDR will have the time of the
dialog timeout or when the called party hangs up. I didn't find a way
to prevent the BYE message from going to both parties on dialog
timeout, but by then the caller side just ignores it with an 481
Transaction Does Not Exist.

if (is_method("BYE")) {
            if(match_dialog_only()) { # this is my hacked match_dialog
which basically just does the load_ctx without triggering the chain
reaction of callbacks
                xlog("$ci: Dialog status is $DLG_status . Direction
$DLG_dir $dlg_val(caller_bye_ts)");
                $var(holdup_time) = $dlg_val(holdup_sec); #get the
dialog holdup timer value
                $var(holdup_time) = $(var(holdup_time){s.int});

                if ($DLG_dir=="downstream" && $var(holdup_time) !=
NULL && $var(holdup_time) > 0) { # only trigger if the caller hung up
and the timer is set
                    xlog("$ci: BYE holdup timer is $var(holdup_time)
seconds. Call has run $DLG_lifetime seconds");

                    if($DLG_lifetime < $var(holdup_time)) {
                        $dlg_val(caller_bye_ts)=""+$Ts; # save the
actual bye receive time to put in a cdr avp
                        $var(holdup_secs) = $var(holdup_time) - $DLG_lifetime;
                        xlog("$ci: BYE holdup timer started for
$var(holdup_secs) seconds.");
                        sl_send_reply("200", "OK");
                        $DLG_timeout = $var(holdup_secs)+1;
                        async(sleep("$var(holdup_secs)"), after_sleep);
                    }
                }
                match_dialog_process(); # match_dialog() would go here
            }
        }
....
route[after_sleep] {
    xlog("$ci: BYE holdup timer finished. Dialog status is $DLG_status");
    if ($DLG_status == 4) { # make sure we haven't received a bye from
the called party
        if (match_dialog_process()) { # you would want to do the
dialog_match() here
            xlog("$ci: Relaying delayed BYE");
            t_relay();
        }
        else {
            xlog("$ci: Dialog not matched. Callee bye preempted.");
        }
    }
    else {
        xlog("$ci: Delayed bye dialog is terminated. Not forwarding.");
    }
    exit;
}

On Thu, Jun 25, 2020 at 11:43 AM ryan embgrets <rembgrets at gmail.com> wrote:
>
> Thanks, Jon , Bogdan for the assistance.
> So, I added the below snippet after the has_totag section of my configuration.
>
>    if (is_method("BYE") && $si = "192.168.10.20") {
>                 if ( load_dialog_ctx("$ci") ) {
>                         xlog("The dialog $var(callid) has an already duration of $DLG_lifetime seconds with $DLG_dir\n");
>                         if($DLG_lifetime < 10 ) {
>                                 $DLG_timeout = 10 - $DLG_lifetime ;
>                                 send_reply(200, "OK");
>                                 exit;
>                         }
>                         unload_dialog_ctx();
>                 }
>         }
>
> And it seems to work, I wanted to check if the above snippet looks good?
>
> Is there a way to send bye to only Carrier side?
>
> I see CDRs get written after dialog timeouts, but can I get CDRs with duration when I receive a bye from the client not on dialog timeout?
>
> Thanks again for your time.
>
> Ryan.
>
>
>
>
>
> On Wed, 24 Jun 2020 at 17:55, Bogdan-Andrei Iancu <bogdan at opensips.org> wrote:
>>
>> Nice one Jon !
>>
>> doing a ++ here, maybe when loading the dialog ctx (before the match),
>> in the call duration is less than 6 secs, you can reply with 200 OK to
>> the BYE and set a dialog timeout for whatever number of sec you still
>> have to get to the 6 secs duration - so when you get to the overall 6
>> secs, OpenSIPS will send the BYEs to both parties.
>>
>> Regards,
>>
>> Bogdan-Andrei Iancu
>>
>> OpenSIPS Founder and Developer
>>    https://www.opensips-solutions.com
>>
>> On 6/23/20 10:43 PM, Jon Abrams wrote:
>> > You may be able to use the load_dialog_ctx()/unload_dialog_ctx()
>> > dialog functions to peek at the dialog when a BYE is received, prior
>> > to invoking match_dialog(). If it is a BYE from the calling party that
>> > you wish to delay, use an async sleep() to delay the call of
>> > match_dialog() and relay of the BYE to the far end. I do something
>> > similar now in 2.2 with a slightly patched dialog module.
>> >
>> > - Jon
>> >
>> >
>> > On Tue, Jun 23, 2020 at 1:58 AM ryan embgrets <rembgrets at gmail.com> wrote:
>> >> Greetings,
>> >>
>> >> I would like to have awesome community suggestions in handling the short duration calls.
>> >>
>> >> My clients send short duration calls towards opensips.
>> >> So if a client sends me BYE within 6 seconds of the call, I would like to terminate the client leg and keep carrier leg alive beyond a few seconds, either by transferring the second leg(carrier side) to freeswitch, or playing some media using rtpengine/rtpproxy at opensips side.
>> >>
>> >> I would like to ask, is it something that can efficiently be done using new capabilities in opensips 3.1?
>> >>
>> >> How do other people handle this?
>> >>
>> >> PS: I cannot restrict my client to not send me short duration calls, so looking for an opensips way to handle this.
>> >>
>> >> Ryan
>> >> _______________________________________________
>> >> Users mailing list
>> >> Users at lists.opensips.org
>> >> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>> > _______________________________________________
>> > Users mailing list
>> > Users at lists.opensips.org
>> > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users



More information about the Users mailing list