Hi Ihor, Thanks for your response. 
This can explain the lingering rtp sessions on RTPEngine. I moved the timeout from default 60 sec down to 5 sec. But still it would be better if I close them directly.




On Tue, 22 Oct 2024 at 10:40, Ihor Olkhovskyi via sr-users <sr-users@lists.kamailio.org> wrote:
Tihomir,

Actually, yes, You need to call rtpengine_delete()

Like this

request_route {
    ....
    if (is_method("CANCEL")) {
        if (t_check_trans()) {
            xlog("L_INFO", "[REQUEST_ROUTE] Relaying in-transaction CANCEL\n");

            # Free previously reserved resourced
            rtpengine_delete();
            ...
        }
        exit;
    }
}

route[WITHINDLG] {
    if (has_totag()) {
        if (loose_route()) {
         ...
            if (is_method("BYE")) {
                xlog("L_INFO", "[WITHINDLG] In-dialog BYE. Invoking rtpengine_delete\n");

                rtpengine_delete();
            }
...
}

failure_route[MANAGE_FAILURE] {
    if ($rs > 299) {
        xlog("L_INFO", "[MANAGE_FAILURE] Transaction failed with $rs > 299, invoking deleting of call on rtpengine\n");

         rtpengine_delete();
    }
}

This is where I do this usually, but you might need to adapt it to your cases.

Le mar. 22 oct. 2024 à 08:27, Tihomir Culjaga via sr-users <sr-users@lists.kamailio.org> a écrit :
Hello, 

I'm using Kamailio + RTPEngine. Everything works well except one thing. I noticed rtp sessions are not being deleted after call termination. Instead, they remain lingering on RTPEngine waiting for a timeout.

kamailio --version
version: kamailio 5.5.2 (x86_64/linux) 55e232
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 55e232
compiled on 14:13:04 Aug 25 2021 with gcc 8.4.1

rtpengine --version
Version: 9.5.1.1-1.el8


rtpengine-ctl list totals tells me every session went to timeout :)

--- snip ---
Total statistics (does not include current running sessions):

 Uptime of rtpengine                             :914 seconds
 Total managed sessions                          :51
 Total rejected sessions                         :0
 Total timed-out sessions via TIMEOUT            :51
 Total timed-out sessions via SILENT_TIMEOUT     :0
 Total timed-out sessions via FINAL_TIMEOUT      :0
 Total timed-out sessions via OFFER_TIMEOUT      :0
 Total regular terminated sessions               :0
 Total forced terminated sessions                :0
--- snip ---




I'm using rtpengine_manage in two routes "route[RELAY]" and onreply_route[MANAGE_REPLY] . Do I need to add a specific rtpengine_delete somewhere ?



route[RELAY] {

        ...

        $xavp(r=>$T_branch_idx) = "replace-origin replace-session-connection";
        if (!nat_uac_test("8")) {
                $xavp(r=>$T_branch_idx) = $xavp(r=>$T_branch_idx) + " trust-address";
        }
        if (!has_totag()) {
                xlog("L_INFO", "NEXIOS: proto = [$proto], ru = [$ru]");
                if ($proto =~ "ws" && !($ru =~ "transport=ws")) {
                        xlog("L_INFO", "####################### FROM WS to any ########################\n");
                        $xavp(r=>$T_branch_idx) = $xavp(r=>$T_branch_idx) + " rtcp-mux-demux DTLS=off SDES-off ICE=remove RTP/AVP direction=external direction=internal";

                } else if (!($proto =~ "ws") && $ru =~ "transport=ws") {
                        xlog("L_INFO", "####################### FROM any to WS ########################\n");
                        setbflag(FLB_TOWEBRTC);
                        $xavp(r=>$T_branch_idx) = $xavp(r=>$T_branch_idx) + " rtcp-mux-offer generate-mid DTLS=active SDES-off ICE=force RTP/SAVPF direction=internal direction=external";

                } else if (($proto =~ "udp") && $ru =~ "transport=udp" && $fs =~ "MY_IP2_ADDR") {
                        xlog("L_INFO", "####################### FROM ?? to ?? $ru ########################\n");

                }
        }
        # we engage RTPEngine
        if (has_body("application/sdp")) {
                xlog("L_INFO", "NEXIOS: # $xavp(r=>$T_branch_idx) #\n");
                rtpengine_manage($xavp(r=>$T_branch_idx));
        }

        if (!t_relay()) {
                sl_reply_error();
        }
        exit;
}


onreply_route[MANAGE_REPLY] {
       
        ...

        $xavp(r=>$T_branch_idx) = "replace-origin replace-session-connection";
        if (!nat_uac_test("8")) {
                $xavp(r=>$T_branch_idx) = $xavp(r=>$T_branch_idx) + " trust-address";
        }
        if (has_totag()) {
                xlog("L_INFO", "onreply_route proto = [$proto], ru = [$ru]");
                if ($proto =~ "ws" && !($ru =~ "transport=ws")) {
                        xlog("L_INFO", "onreply_route ####################### FROM WS to any ########################\n");
                        $xavp(r=>$T_branch_idx) = $xavp(r=>$T_branch_idx) + " rtcp-mux-demux DTLS=off SDES-off ICE=remove RTP/AVP direction=external direction=internal";

                } else if (!($proto =~ "ws") && $ru =~ "transport=ws") {
                        xlog("L_INFO", "onreply_route ####################### FROM any to WS ########################\n");

                        setbflag(FLB_TOWEBRTC);
                        $xavp(r=>$T_branch_idx) = $xavp(r=>$T_branch_idx) + " rtcp-mux-offer generate-mid DTLS=active SDES-off ICE=force RTP/SAVPF direction=internal direction=external";

                } else if (($proto =~ "udp") && $ru =~ "transport=udp" && $fs =~ "MY_IP2_ADDR") {
                        xlog("L_INFO", "onreply_route ####################### FROM ?? to ?? $ru ########################\n");

                }

        }
        if (has_body("application/sdp")) {
                xlog("L_INFO", "onreply_route # $xavp(r=>$T_branch_idx) #\n");
                rtpengine_manage($xavp(r=>$T_branch_idx));
        }
}



Any ideas are appreciated.

Regards,
Tihomir.

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:


--
Best regards,
Ihor (Igor)
__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
To unsubscribe send an email to sr-users-leave@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe: