You can't send Cancel from the server side, it has to be sent by originator of the initial request.
BYE ends successfull dialog, so it can't be sent also as you do not establish the dialog yet.

On Tue, 14 Mar 2023, 18:56 , <jhayhoe@liquidweb.com> wrote:
I am looking to configure Kamailio and RTPEngine to play a wav file for any new calls during a scheduled asterisk server maintenance. I have set up the following within route{} to send the call to a early_media route based on a variable that I can set on the server using kamcmd.

route {
...
       if ($sht(config=>maint)=="1") {
            if (is_method("INVITE") && !has_totag()) {
                xlog ("L_INFO","Ongoing maintenance. Call-ID:$ci | Method: $rm");
                route(early_media);
            }
        }
...
}

route[early_media] {
    xlog("Maintenance: handling early_media\n");
    rtpengine_manage("direction=external direction=external");
    $var(body) = $(rb{re.subst,/(IP4.).*/\1##server IP redacted##/g});
    set_reply_body($var(body), "application/sdp");
    t_send_reply("183", "Session Progress");
    sleep(2);
    unblock_dtmf("all");
    play_media("file=/etc/kamailio/media/maintenance.wav");
    sleep(21);
    rtpengine_delete();
    t_reply("480","Temporarily Unavailable");
}

This mostly works as I hear the recorded message in place of the ringing tone when a call is processed by kamailio and then a busy signal is heard as part of the 480 reply at the end. The sleep's are in place to match the duration of the recorded message as otherwise the 480 is sent immediately following the start of the play_media. Feel free to let me know if there is a better solution to wait the duration of the media file and then proceed with processing instead of using sleep().

Is there a way to instead send a CANCEL or a BYE instead of a 480 after the wav file is played? I tried using t_cancel_callid("$ci", "$cs", "0") as well as a dlg_bye("all") at the end of the early_media route and neither seemed to send any headers out.
__________________________________________________________
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: