Hello,

failure_route was designed to work only for incoming requests that are routed out, not for local generated requests. What you can do, is to loop the local requests back to kamailio and then sending out.

Enabling failure route for local requests may require a lot of code review, because of all functions implemented by different modules to be used there, which expect a proper SIP request as received from the network.

Cheers,
Daniel

On 05.03.19 12:31, Luis Azedo wrote:

Hi,

i have a use case where i need to use failure_route for local transactions like this.

route[TIMER_ROUTE]
{
    ... do sql
    while rows
      t_uac_send ...
}

event_route[tm:local-request]
{
    if this is my request
       t_on_reply("MY_REPLY");
       t_on_failure("MY_FAULT");
       t_set_fr(0, MY_TIMEOUT);
       handle_ruri_alias();
       record_route();      
}

but MY_FAULT is never called even for 408 (timeout)

i tracked down to t_reply:run_failure_handlers where the check fails.
...
struct sip_msg *shmem_msg = t->uas.request;
...
if (!shmem_msg) {
LM_WARN("no UAC support (%d, %d) \n", on_failure, t->tmcb_hl.reg_types);
return 0;
}
...

i changed the code a bit  to check for is_local and parse the the request and it works for me, however i would like other to comment on this approach as there may be a simpler solution.
thanks

if (!shmem_msg) {
sip_msg_t local_msg;

if(!is_local(t)) {
LM_WARN("no UAC support (%d, %d) \n", on_failure, t->tmcb_hl.reg_types);
return 0;
}

/* parse the retr. buffer */
memset(&local_msg, 0, sizeof(struct sip_msg));
local_msg.buf = t->uac[picked_branch].request.buffer;
local_msg.len = t->uac[picked_branch].request.buffer_len;
if (parse_msg(local_msg.buf, local_msg.len, &local_msg) != 0) {
LM_ERR("failed to parse retr buffer (weird!): \n%.*s\n",
(int)local_msg.len, local_msg.buf);
return 0;
}

t->uas.request = sip_msg_shm_clone(&local_msg, NULL, 1);

free_sip_msg(&local_msg);

if(!t->uas.request) {
LM_ERR("UAS REQ IS NULL AFTER PARSE \n");
return 0;
}

shmem_msg = t->uas.request;

}




_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - May 6-8, 2019 -- www.kamailioworld.com
Kamailio Advanced Training - Mar 25-27, 2019, in Washington, DC, USA -- www.asipto.com