Hello List,

I'm finishing my implementation of LCR with kamailio for outgoing calls but one use case does not work.
Let me explain:
- I have some sbc for one destination. If one destination fail, kamailio try to second one etc..
- If no SBC is available for this destination (for exemple, all are down), i want to send my call to an error server (asterisk), play an error sound.

To accomplish this, i re-write the RURI: "sip:error1@errorserver.local", and launch RELAY route. But kamailio dont make a DNS query to find IP of "errorserver.local", only change RURI and try to send to the last LCR gateway.

I have also try to add a new branch, but same result... Why kamailio do not make a new DNS query ?

route[RELAY] {
        #if (is_method("INVITE")) {
        #       if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");
        #}

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


route[NOTFOUND]{
        $ru = "sip:error1@errorserver.local";
        xlog("L_WARN", "[$ci]|$si|Routing this call to $ru (error server)\n");
        append_branch($ru);
        route(RELAY);
}


route[LCR] {
        xlog("L_INFO", "[$ci]|$si|Loading gateways...\n");
        if (!load_gws(1)) {
                xlog("L_ERR", "[$ci]|$si|Can't load LCR gateways\n");
                sl_send_reply("503", "Unable to load gateways");
                exit;
        } else {
                $var(i) = 0;
                while(is_avp_set("$(avp(i:709)[$var(i)])")) {
                        xlog("L_INFO", "[$ci]|$si|This gateway was found: gw_uri_avp[$var(i)]=$(avp(i:709)[$var(i)]) \n");
                        $var(i) = $var(i) + 1;
                };

                if(is_avp_set("$avp(i:709)")) {
                        xlog("L_INFO", "[$ci]|$si|Trying gateway ‘$avp(i:709)’\n");
                } else {
                        xlog("L_INFO", "[$ci]|$si|No more gateways. Goto route NOTFOUND...\n");
                        route(NOTFOUND);
                };

                # try the first matched gateway
                if (next_gw()) {
                        xlog("L_INFO", "[$ci]|$si|New request URI built: $ru . Relaying it (and arming backup destination if needed).");
                        # Route to failure for failover
                        t_on_failure("lcrfailure");
                        route(RELAY);
                } else {
                        xlog("L_INFO", "[$ci]|$si|No more gateways (after next_gw()). Goto route NOTFOUND...");
                        route(NOTFOUND);
                };
        };
        exit;
}

failure_route[lcrfailure] {

        # the previous gateway is no good
        if (t_check_status("408|50[34]")) {
                xlog("L_WARN", "[$ci]|$si|Entering in entering failure_route[lcrfailure]. Error code: $T_reply_code \n");
                if(is_avp_set("$avp(i:709)")) {
                        xlog("L_INFO", "[$ci]|$si|Trying gateway ‘$avp(i:709)’\n");
                } else {
                        xlog("L_ERR", "[$ci]|$si|AVP is not set\n");
                };

                if (next_gw()) {
                        xlog("L_INFO", "[$ci]|$si|New request URI built: $ru . Relaying it (and arming backup destination if needed).");
                        # Route to failure for failover
                        t_on_failure("lcrfailure");
                        route(RELAY);
                } else {
                        xlog("L_INFO", "[$ci]|$si|No more gateways (after next_gw()). Goto route NOTFOUND...");
                        route(NOTFOUND);
                };
        exit;
        };
}


Many thanks,
Regards.