<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>iirc, the function was developed before the branch failure route
      was added, mostly intended to be used in the onreply route for
      provisional responses (i.e., 100-199). I see it is allowed in any
      route, but there is no purpose for it at least in the failure
      route, where the transaction cannot be cancelled any more, because
      is already in terminated state.<br>
    </p>
    <p>So, if it is a single branch, then triggering a cancel in event
      route branch failure is not useful.</p>
    <p>Maybe it should be tried also with t_cancel_branches(), but in
      onreply route, when the status is >=300.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 07.06.22 08:27, Henning Westerholt
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:AM6PR05MB5409C42D692089B4CE7912E2BFA59@AM6PR05MB5409.eurprd05.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}span.E-MailFormatvorlage18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}div.WordSection1
        {page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hello,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB">this might be a bug in the tmx module function,
            according to the docs it should work for all branches.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB">Please open an issue on our github tracker
            about it, with the details for reproducing it.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB">Cheers,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB">Henning<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB">-- <o:p>
            </o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB">Henning Westerholt –
          </span><span style="mso-fareast-language:EN-US"><a
              href="https://skalatan.de/blog/" moz-do-not-send="true"><span
                style="color:#0563C1" lang="EN-GB">https://skalatan.de/blog/</span></a></span><span
            style="mso-fareast-language:EN-US" lang="EN-GB"><o:p></o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB">Kamailio services –
          </span><span style="mso-fareast-language:EN-US"><a
              href="https://gilawa.com/" moz-do-not-send="true"><span
                style="color:#0563C1" lang="EN-GB">https://gilawa.com</span></a></span><span
            style="mso-fareast-language:EN-US" lang="EN-GB"><o:p></o:p></span></p>
        <p class="MsoNormal"><span style="mso-fareast-language:EN-US"
            lang="EN-GB"><o:p> </o:p></span></p>
        <div style="border:none;border-top:solid #E1E1E1
          1.0pt;padding:3.0pt 0cm 0cm 0cm">
          <p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b>
            sr-users <a class="moz-txt-link-rfc2396E" href="mailto:sr-users-bounces@lists.kamailio.org"><sr-users-bounces@lists.kamailio.org></a>
            <b>On Behalf Of </b>Pavel Veselovsky<br>
            <b>Sent:</b> Tuesday, June 7, 2022 6:49 AM<br>
            <b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
            <b>Subject:</b> [SR-Users] t_cancel_callid - doesn't insert
            Reason header, if called from branch 0<o:p></o:p></p>
        </div>
        <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
        <div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">Hallo<o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">so far I
              have no reaction on my question.<o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">Has anybody
              similar experience that  t_cancel_callid() doesn't insert
              Reason header, if called from branch 0?<o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">What are
              differences between branch 0 and other branches?<o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">Regards.<o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">Pavel.<o:p></o:p></p>
          </div>
          <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
          <div>
            <div>
              <p class="MsoNormal" style="margin-left:35.4pt">On Fri,
                Jun 3, 2022 at 3:17 PM Pavel Veselovsky <<a
                  href="mailto:pavel.veselovsky@gmail.com"
                  moz-do-not-send="true" class="moz-txt-link-freetext">pavel.veselovsky@gmail.com</a>>
                wrote:<o:p></o:p></p>
            </div>
            <blockquote style="border:none;border-left:solid #CCCCCC
              1.0pt;padding:0cm 0cm 0cm
              6.0pt;margin-left:4.8pt;margin-right:0cm">
              <div>
                <p class="MsoNormal" style="margin-left:35.4pt">Hallo
                  all, <o:p></o:p></p>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
                </div>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt">I
                    defined  branch_failure routing  block via
                    t_on_branch_failure()<o:p></o:p></p>
                </div>
                <p class="MsoNormal" style="margin-left:35.4pt">In the
                  branch_failure route, in case of "408 Request timeout"
                  I am sending CANCEL with reason
                  "t_cancel_callid("$ci", "$cs", "22", "408")".<o:p></o:p></p>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
                </div>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt">If
                    the t_cancel_callid("$ci", "$cs", "22", "408") is
                    called in  branch_failure for branch idx 0, the
                    CANCEL is sent, but Reason header is missing there.<o:p></o:p></p>
                </div>
                <div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt">Why? 
                      (I expect that t_cancel_callid() should insert
                      Reason header regardless of branch it is called
                      from)<o:p></o:p></p>
                  </div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
                  </div>
                </div>
                <div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt">If
                      the t_cancel_callid is called in branch idx !=0,
                      the CANCEL contains Reason header with cause as
                      expected.<o:p></o:p></p>
                  </div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
                  </div>
                </div>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt">Thanks
                    for clarification of this behavior, <o:p></o:p></p>
                </div>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt">Pavel.  <o:p></o:p></p>
                </div>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
                </div>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt">P.S.
                    code snipset:<o:p></o:p></p>
                </div>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt">event_route[tm:branch-failure:primary]<o:p></o:p></p>
                </div>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt">{<o:p></o:p></p>
                </div>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt"> if
                    ($T(reply_code) == "408")<o:p></o:p></p>
                </div>
                <p class="MsoNormal" style="margin-left:35.4pt">    {<br>
                          if ($avp(branch_idx) == $T_branch_idx)<br>
                          {<br>
                              if (t_cancel_callid("$ci", "$cs", "22",
                  "408"))<br>
                              {<br>
                                  xlog("L_INFO", "CANCEL sent ci:$ci,
                  cs:$cs 408");    <br>
                              }<br>
                              else<br>
                              {<br>
                                  xlog("L_INFO", "CANCEL not sent ...
                  ci:$ci, cs:$cs 408");<br>
                              }<br>
                  <br>
                              $var(_palotmp_) = "sip:" +
                  $avp(replaced_cfnry_target_number) + "@" + $dd + ":" +
                  $dp + ";user=phone";            <br>
                              append_branch($var(_palotmp_),"1.0");<br>
                  <br>
                              t_relay();<br>
                              return;<br>
                          }<br>
                      }<o:p></o:p></p>
                <div>
                  <p class="MsoNormal" style="margin-left:35.4pt">}<o:p></o:p></p>
                </div>
                <div>
                  <div>
                    <p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
                  </div>
                </div>
              </div>
            </blockquote>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * <a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</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 Advanced Training - Online: June 20-23, 2022
  * <a class="moz-txt-link-freetext" href="https://www.asipto.com/sw/kamailio-advanced-training-online/">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
  </body>
</html>