Hi Aqs,
Thanks for the reply.
Without the append_branch() the headers are set but the rewritehostport() doesn't work and the request is re-sent to the PSTN gateway.

On Mon, 17 Dec 2018, at 3:51 PM, Aqs Younas wrote:
Remove append_branch().

On Mon, 17 Dec 2018 at 6:08 AM, Boden Garman <bpgarman@fastmail.fm> wrote:

Hi list,

I'm trying to play an announcement for my users when my PSTN gateway responds with a 404 Not Found (Reason: Q.850;cause=3), indicating a wrong number. I'm a bit lost and would appreciate any advice.

What I am seeing is two parallel SIP invites, one to my announcement server (hooray!) and one to the PSTN gateway again (which I don't want). How do I stop the original branch from starting again?

I've tried changing the order of rewritehostport and append_branch without any difference. I've also tried to use t_relay() instead of the RELAY route.

I'm using Kamailio 5.1 and have modified the deafult kamailio.cfg

Thanks!
Boden

I think this is the relevant parts of the config:

# PSTN GW routing
route[PSTN] {
         [PSTN regex logic omitted]

        # classify as an outbound call
        set_dlg_profile("outbound_calls");

        # select a PSTN gateway from the dispatcher
        if (!ds_select_dst("66", "8")) {
                send_reply("404", "No destination");
                exit;
        }

        # failover if the selected PSTN gateway is down
        t_on_failure("RTF_DISPATCH");

        route(RELAY);
        exit;
}


# Try next destinations in failure route
failure_route[RTF_DISPATCH] {
        xlog("inside RTF_DISPATCH");
        if (t_is_canceled()) {
                exit;
        }

        # wrong number from PSTN
        if (t_check_status("404")) {
                append_branch();
                append_hf("X-Application: announcement\r\n");
                append_hf("X-Announcement-Playback: wrong-number\r\n");
                route(TO_ANNOUNCEMENT);
                exit;
        }

        # next DST - only for 500 or local timeout
        if (t_check_status("500") or (t_branch_timeout() and !t_branch_replied())) {
                xlog("selecting next destination");
                if (ds_next_dst()) {
                        t_on_failure("RTF_DISPATCH");
                        route(RELAY);
                        exit;
                }
        }
}


# Routing to announcement server
route[TO_ANNOUNCEMENT] {
        if (!is_method("INVITE")) {
                return;
        }
        rewritehostport('ANNOUNCEMENT_SERVER:5060');
        route(RELAY);
        exit;
}
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users