<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hello,</p>
    <p>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.</p>
    <p>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.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 05.03.19 12:31, Luis Azedo wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAEvFzR_edOPJ+ELue6G2j7w+HaSA6BxC3G9VL=_j=sWi3tH_Sg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">
            <div dir="ltr">
              <div dir="ltr">
                <div dir="ltr">
                  <div dir="ltr">
                    <div dir="ltr"><br>
                    </div>
                    Hi,
                    <div><br>
                    </div>
                    <div>i have a use case where i need to use
                      failure_route for local transactions like this.</div>
                    <div><br>
                    </div>
                    <div>route[TIMER_ROUTE]</div>
                    <div>{</div>
                    <div>    ... do sql</div>
                    <div>    while rows</div>
                    <div>      t_uac_send ...</div>
                    <div>}</div>
                    <div><br>
                    </div>
                    <div>
                      <div>event_route[tm:local-request]</div>
                      <div>{</div>
                    </div>
                    <div>    if this is my request</div>
                    <div>       t_on_reply("MY_REPLY");</div>
                    <div>       t_on_failure("MY_FAULT");</div>
                    <div>       t_set_fr(0, MY_TIMEOUT);</div>
                    <div>       handle_ruri_alias();</div>
                    <div>       record_route();      </div>
                    <div>}</div>
                    <div><br>
                    </div>
                    <div>but MY_FAULT is never called even for 408
                      (timeout)</div>
                    <div><br>
                    </div>
                    <div>i tracked down to t_reply:run_failure_handlers
                      where the check fails.</div>
                    <div>...</div>
                    <div>struct sip_msg *shmem_msg = t->uas.request;</div>
                    <div>...</div>
                    <div>
                      <div><span style="white-space:pre"> </span>if
                        (!shmem_msg) {</div>
                      <div><span style="white-space:pre">         </span>LM_WARN("no
                        UAC support (%d, %d) \n", on_failure,
                        t->tmcb_hl.reg_types);<br>
                      </div>
                      <div><span style="white-space:pre">         </span>return
                        0;</div>
                      <div><span style="white-space:pre"> </span>}</div>
                    </div>
                    <div>...</div>
                    <div><br>
                    </div>
                    <div>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.</div>
                    <div>thanks</div>
                    <div><br>
                    </div>
                    <div>
                      <div><span style="white-space:pre"> </span>if
                        (!shmem_msg) {</div>
                      <div><span style="white-space:pre">         </span>sip_msg_t
                        local_msg;</div>
                      <div><br>
                      </div>
                      <div><span style="white-space:pre">         </span>if(!is_local(t))
                        {</div>
                      <div><span style="white-space:pre">                 </span>LM_WARN("no
                        UAC support (%d, %d) \n", on_failure,
                        t->tmcb_hl.reg_types);</div>
                      <div><span style="white-space:pre">                 </span>return
                        0;</div>
                      <div><span style="white-space:pre">         </span>}</div>
                      <div><br>
                      </div>
                      <div><span style="white-space:pre">         </span>/*
                        parse the retr. buffer */</div>
                      <div><span style="white-space:pre">         </span>memset(&local_msg,
                        0, sizeof(struct sip_msg));</div>
                      <div><span style="white-space:pre">         </span>local_msg.buf
                        = t->uac[picked_branch].request.buffer;</div>
                      <div><span style="white-space:pre">         </span>local_msg.len
                        = t->uac[picked_branch].request.buffer_len;</div>
                      <div><span style="white-space:pre">         </span>if
                        (parse_msg(local_msg.buf, local_msg.len,
                        &local_msg) != 0) {</div>
                      <div><span style="white-space:pre">                 </span>LM_ERR("failed
                        to parse retr buffer (weird!): \n%.*s\n",</div>
                      <div><span style="white-space:pre">                                 </span>(int)local_msg.len,
                        local_msg.buf);</div>
                      <div><span style="white-space:pre">                 </span>return
                        0;</div>
                      <div><span style="white-space:pre">         </span>}</div>
                      <div><br>
                      </div>
                      <div><span style="white-space:pre">         </span>t->uas.request
                        = sip_msg_shm_clone(&local_msg, NULL, 1);</div>
                      <div><br>
                      </div>
                      <div><span style="white-space:pre">         </span>free_sip_msg(&local_msg);</div>
                      <div><br>
                      </div>
                      <div><span style="white-space:pre">         </span>if(!t->uas.request)
                        {</div>
                      <div><span style="white-space:pre">                 </span>LM_ERR("UAS
                        REQ IS NULL AFTER PARSE \n");</div>
                      <div><span style="white-space:pre">                 </span>return
                        0;</div>
                      <div><span style="white-space:pre">         </span>}</div>
                      <div><br>
                      </div>
                      <div><span style="white-space:pre">         </span>shmem_msg
                        = t->uas.request;</div>
                      <div><br>
                      </div>
                      <div><span style="white-space:pre"> </span>}</div>
                    </div>
                    <div><br>
                    </div>
                    <div><br>
                    </div>
                    <div>
                      <div class="gmail_quote">
                        <blockquote class="gmail_quote"
                          style="margin:0px 0px 0px
                          0.8ex;border-left:1px solid
                          rgb(204,204,204);padding-left:1ex"><br>
                        </blockquote>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Development Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.kamailio.org">sr-dev@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio World Conference - May 6-8, 2019 -- <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a>
Kamailio Advanced Training - Mar 25-27, 2019, in Washington, DC, USA -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a></pre>
  </body>
</html>