Benoît,

When you make t_relay for the packet for the first time, it's content "freezes" and would be unchanged for next failure -> t_relay.
In short words, every time you will go to failure_route, you'll get the original contents of the packet was on the very first t_relay.
At least, this is how I do understand this logic, maybe developers can correct me here, but I've never experienced other behavior.

пн, 28 февр. 2022 г. в 13:55, Benoît Panizzon <benoit.panizzon@imp.ch>:
Hi Igor

> On which route do you send those variables?

Trying to shorten a bit.

Example, call is being sent to a customer device and is getting busy,
this is sent to an asterisk to play the 'busy' tone. But this
is also done with all other kinds of announcements.

        if t_check_status("(486)|(600)") {
                # BUSY
                $avp(announcecode) = "BUSY";
                route(DISPATCHMEDIA);
                exit;
        }

DISPMEDIA contains the ID of a dispatcher group consisting of
two sip URI towards our two asterisk media server.

Extra Header are the used by asterisk to play the desired
announcement in the desired language.

route[DISPATCHMEDIA]
        $avp(dispgroup) = DISPMEDIA;
        append_hf("IMP-annc: $avp(announcecode)\r\n");
        append_hf("IMP-mandate: $avp(mandate)\r\n");
        append_hf("IMP-language: $avp(callerlang)\r\n");
        if (ds_select_dst("$avp(dispgroup)", "6")) {
                # we have a list of servers and a selection in $du
                if ($avp(debug) > 0) {
                        xlog("L_INFO", "     --> DISPMEDIA targeting request to $ru to location $du \n");
                }
                # Trigger failure route
                t_on_failure("DISPATCH_MEDIA_FAILURE");
                t_on_reply("DISPMEDIA_MANAGE_REPLY");
                route(RELAY);
                exit;
        }
        route(ANNOUNCEREPLY);
        exit;
}

See part below commented by XXXX where I already 'fixed' it by adding the header
again and I also had to set $rU again as this was reset to $rU of orininal incomming
call containing a ported number routing prefix, which we strip as one of the first
things to get the e164 number.

failure_route[DISPATCH_MEDIA_FAILURE]
{
        if (t_is_canceled()) {
                exit;
        }
        if (t_check_status("(500)|(503)") or (t_branch_timeout() and !t_branch_replied())) {
                if (ds_next_dst()) {
                        # XXXX SETTING HEADER AGAIN!?!
                        append_hf("IMP-annc: $avp(announcecode)\r\n");
                        append_hf("IMP-mandate: $avp(mandate)\r\n");
                        append_hf("IMP-language: $avp(callerlang)\r\n");
                        if ($avp(debug) > 0) {
                                xlog("L_INFO", "     --> $cfg(route): retargeting request to $ru to location $du \n");
                        }
                        # Trigger failure route again
                        t_on_failure("DISPATCH_MEDIA_FAILURE");
                        t_on_reply("DISPMEDIA_MANAGE_REPLY");
                        route(RELAY);
                        exit;
                }
                route(ANNOUNCEREPLY);
                exit;
        }
}

I know about how Kamailio works by reading header from an 'input buffer'
and writing to an 'output buffer'.

I guess in case of t_on_failure the complete output buffer with corrected
$ru and additional header is being discarded so I have to do all changes again?

--
Mit freundlichen Grüssen

-Benoît Panizzon- @ HomeOffice und normal erreichbar
--
I m p r o W a r e   A G    -    Leiter Commerce Kunden
______________________________________________________

Zurlindenstrasse 29             Tel  +41 61 826 93 00
CH-4133 Pratteln                Fax  +41 61 826 93 01
Schweiz                         Web  http://www.imp.ch
______________________________________________________


--
Best regards,
Igor