[SR-Users] Serial forking

Daniel Tryba d.tryba at pocos.nl
Mon May 28 17:12:42 CEST 2018


On Mon, May 28, 2018 at 04:55:30PM +0200, igor.potjevlesch at gmail.com wrote:
> I know that the default behaviour of two aliases in kamailio.aliases result
> in parallel forking.
> 
> I'm wondering if its possible to do serial forking instead? For example, in
> case that the first INVITE has no 180/183, or neither 100 Trying, then send
> the INVITE to the second entry?

Offcourse, fiddle with t_set_fr on a per call basis or the
fr_inv_timer/fr_timer:
http://www.kamailio.org/docs/modules/5.2.x/modules/tm.html#tm.f.t_set_fr

SERIALRELAY is used in stead of the normal RELAY route, it loads available
endpoints with t_load_contacts:
http://www.kamailio.org/docs/modules/5.2.x/modules/tm.html#tm.f.t_load_contacts
and fetches the first one with t_next_contacts.
In the failure route keep calling t_next_contacts till there are no more.

route[SERIALRELAY] {
        if (is_method("INVITE|SUBSCRIBE")) {
                t_on_branch("MANAGE_BRANCH");
                t_on_reply("MANAGE_REPLY");
        }
        if (is_method("INVITE")) {
                t_load_contacts();
                t_next_contacts();

                t_on_failure("SERIAL_FAILURE");
        }

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

        break;
}

failure_route[SERIAL_FAILURE] {
        if (!t_next_contacts())
        {
                send_reply("408","Timeout or nobody available");

                exit;
        }

        t_on_branch("MANAGE_BRANCH");
        t_on_reply("MANAGE_REPLY");
        t_on_failure("SERIAL_FAILURE");

        t_relay();
}




More information about the sr-users mailing list