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?