<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <tt>try via $(<reply>hdr(Reason)) in failure route, but be
      sure that the 402 is the winning reply, triggering the failover
      route.<br>
      <br>
      Regards,<br>
    </tt>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a class="moz-txt-link-freetext" href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a>
OpenSIPS Bootcamp 2021 online
  <a class="moz-txt-link-freetext" href="https://opensips.org/training/OpenSIPS_eBootcamp_2021/">https://opensips.org/training/OpenSIPS_eBootcamp_2021/</a></pre>
    <div class="moz-cite-prefix">On 4/16/21 2:59 PM, solarmon wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAOXfywO3aH_et0P8F0kki+Gs77SXjmLkvNbVJ+ckRN-5tmdoBQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi Bogdan,
        <div><br>
        </div>
        <div>It is in the response coming back to us from the dispatcher
          endpoint. In this case, it is an 402 Bad Gateway message,
          which has a Reason header with the cause code in it.</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Fri, 16 Apr 2021 at 12:43,
          Bogdan-Andrei Iancu <<a href="mailto:bogdan@opensips.org"
            moz-do-not-send="true">bogdan@opensips.org</a>> wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div> <tt>Where do you want to extract the Reason from (like
              sip msg) ?<br>
              <br>
              Regards,<br>
            </tt>
            <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank" moz-do-not-send="true">https://www.opensips-solutions.com</a>
OpenSIPS Bootcamp 2021 online
  <a href="https://opensips.org/training/OpenSIPS_eBootcamp_2021/" target="_blank" moz-do-not-send="true">https://opensips.org/training/OpenSIPS_eBootcamp_2021/</a></pre>
            <div>On 4/16/21 1:28 PM, solarmon wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">Hi Bogdan,
                <div><br>
                </div>
                <div>Thanks for the response amd link
                  to append_to_reply()</div>
                <div><br>
                </div>
                <div>What is the best function to use to extract the
                  Reason header to feed in to append_to_reply()?</div>
                <div><br>
                </div>
                <div>Thank you.</div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Fri, 16 Apr 2021 at
                  11:07, Bogdan-Andrei Iancu <<a
                    href="mailto:bogdan@opensips.org" target="_blank"
                    moz-do-not-send="true">bogdan@opensips.org</a>>
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote" style="margin:0px 0px
                  0px 0.8ex;border-left:1px solid
                  rgb(204,204,204);padding-left:1ex">
                  <div> <tt>Hi,<br>
                      <br>
                      use the append_to_reply() function<br>
                      <br>
                      <a
href="https://opensips.org/html/docs/modules/3.1.x/sipmsgops.html#func_append_to_reply"
                        target="_blank" moz-do-not-send="true">https://opensips.org/html/docs/modules/3.1.x/sipmsgops.html#func_append_to_reply</a><br>
                      <br>
                      Regards,<br>
                    </tt>
                    <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank" moz-do-not-send="true">https://www.opensips-solutions.com</a>
OpenSIPS Bootcamp 2021 online
  <a href="https://opensips.org/training/OpenSIPS_eBootcamp_2021/" target="_blank" moz-do-not-send="true">https://opensips.org/training/OpenSIPS_eBootcamp_2021/</a></pre>
                    <div>On 4/16/21 12:22 PM, solarmon wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">Hi,<br>
                        <div><br>
                        </div>
                        <div>We have a code that response back with a
                          "503 Service not available" if it has
                          exhausted all the dispatcher endpoints - see
                          end of email.</div>
                        <div><br>
                        </div>
                        <div>It would be useful if we casn send back the
                          Reason header of the last rejection. Could
                          this be done and what should I look at?</div>
                        <div><br>
                        </div>
                        <div>Thank you!</div>
                        <div><br>
                        </div>
                        <div>failure_route[call_failover]<br>
                          {<br>
                                  xlog("[$ci] call failed to established
                          with $T_reply_code code\n");<br>
                          <br>
                                  rtpproxy_unforce("$avp(rtpp_set)");<br>
                          <br>
                                  if (t_was_cancelled()) {<br>
                                          t_reply("487","Request
                          cancelled");<br>
                                          exit;<br>
                                  }<br>
                          <br>
                                  # any failure indication ?<br>
                                  if ( t_check_status("[56][0-9][0-9]")<br>
                                  || (t_check_status("408") &&
                          t_local_replied("all"))<br>
                                  ) {<br>
                                          xlog("[$ci] destination $rd
                          failed  with $T_reply_code -> retry\n ");<br>
                          <br>
                                          ###ds_mark_dst("p");<br>
                          <br>
                                          if ( ds_next_domain() ) {<br>
                                                  xlog("[$ci] using new
                          destination <$rd>\n ");<br>
                          <br>
                                                  # send it out again<br>
                                                 
                          t_on_failure("call_failover");<br>
                                                  t_relay();<br>
                                                  exit;<br>
                                          } else {<br>
                                                  xlog("[$ci] no other
                          destination to retry\n ");<br>
                                                  t_reply("503","Service
                          not available");<br>
                                                  exit;<br>
                                          }<br>
                                  }<br>
                          <br>
                                  # if call failure, allow the reply to
                          propagate to caller<br>
                                  exit;<br>
                          }<br>
                        </div>
                      </div>
                      <br>
                      <fieldset></fieldset>
                      <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank" moz-do-not-send="true">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank" moz-do-not-send="true">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
                    </blockquote>
                    <br>
                  </div>
                </blockquote>
              </div>
            </blockquote>
            <br>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>