<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <tt>Hi Pat,<br>
      <br>
      In the branch route you cannot use any signaling function - the
      branch route is there just for exploring and changing the SIP
      message (in a per branch manner). What you can do is to drop a
      branch (to tell OpenSIPS not to send that branch out) by using the
      "drop()" function.<br>
      <br>
      Still, you can do parallel forking without the need of branch
      route - again, the branch route is optionally there if you want to
      individually changes the branches (like for the branch going to a
      GW to add the RPID hdr, but not for the branch going to a user).
      If you deal with the branches in the same way, there is no need
      for a branch 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="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
    <div class="moz-cite-prefix">On 01/26/2017 05:08 AM, Pat Burke
      wrote:<br>
    </div>
    <blockquote
      cite="mid:1483b0bc32bcb3024971a5da985683d8@voxtelesys.com"
      type="cite">
      <title></title>
      <div class="iw_mail" dir="ltr">Hello,
        <div><br>
        </div>
        <div>I have an opensips server that I use for routing.  I
          receive a call and will attempt multiple carriers to complete
          the call.  My understanding is that in 2.2 I had to use
          branch_route to be able to make multiple attempts.  What I am
          running into now is that when I get a SIP response that
          indicates that I don't want to try another carrier, or I have
          tried as many as I want to try, then I want to send a SIP
          response (ether the response from the last carrier or a
          response of my own) and end the call.  When I t_reply I get
          the following error </div>
        <div>            "CRITICAL:tm:w_t_reply: unsupported route_type
          (8)".</div>
        <div><br>
        </div>
        <div>In a nutshell, the flow is</div>
        <div><br>
        </div>
        <div>1)  Call flow leads to RELAY_TO_EGRESS to make the first
          call.</div>
        <div>2)  RELAY_TO_EGRESS sets up the call information by calling
          OUTBOUND_SETUP (which will attempt to terminate the call if
          there are errors or no more carriers) and then creates a
          branch to handle the attempt (BRANCH_TO_EGRESS)</div>
        <div>3)  BRANCH_TO_EGRESS does some final setup (setting up
          headers, etc) and sets the t_on_failure to "egress_failed"</div>
        <div>4)  If the call attempt fails, "egress_failed" is called
          which may want to terminate the call (send_reply...) or
          attempt again by calling TRY_CARRIER_FAILOVER</div>
        <div>5) TRY_CARRIER_FAILOVER will start the process again by
          calling RELAY_TO_EGRESS (which usually ends in the call to
          OUTBOUND_SETUP because that is where it determines when no
          more attempts are going to be made).</div>
        <div><br>
        </div>
        <div>In 1.11 without branching this worked fine.</div>
        <div><br>
        </div>
        <div>
          <div>What is the correct way to architect the code.  Here is
            the general structure I have now.</div>
          <div><br>
          </div>
        </div>
        <div>...</div>
        <div><br>
        </div>
        <div>
          <div>route[RELAY_TO_EGRESS] {</div>
          <div>    route(OUTBOUND_SETUP);</div>
          <div>    t_on_branch("BRANCH_TO_EGRESS");</div>
          <div><br>
          </div>
          <div>    if (!t_relay("0x01")) {</div>
          <div>        send_reply("500","Internal Error");</div>
          <div>        exit;</div>
          <div>    }</div>
          <div>}</div>
          <div><br>
          </div>
          <div>
            <div>route[OUTBOUND_SETUP] {</div>
            <div>...</div>
            <div>                if ($avp(current_carrier_idx) ==
              $avp(out_routes_no)) {</div>
            <div>                    route(NO_ROUTES_AVAILABLE, "No more
              routes available.");</div>
            <div>                }</div>
            <div>...</div>
          </div>
          <div>    if (!route(VALIDATE_CARRIER)) {</div>
          <div>        route(TRY_CARRIER_FAILOVER, "503", "In
            supplemental exclusion.");</div>
          <div>        return(1);</div>
          <div>    }</div>
          <div>}</div>
          <div><br>
          </div>
          <div>
            <div>branch_route[BRANCH_TO_EGRESS] {</div>
          </div>
          <div>...</div>
          <div>    t_on_failure("egress_failed");</div>
          <div>...</div>
          <div>}</div>
          <div><br>
          </div>
          <div>route[NO_ROUTES_AVAILABLE] {</div>
          <div>    xlog("L_WARN", "$rU SCRIPT:EGRESS:WARN: No carriers
            to route to.  Ending the call \n");</div>
          <div>    $avp(error_reason) := $avp(error_reason) + $param(1);</div>
          <div>    t_reply("503","Service not available.");</div>
          <div>    exit;</div>
          <div>}</div>
          <div><br>
          </div>
          <div>
            <div>failure_route[egress_failed] {</div>
            <div>...</div>
            <div>    if (t_was_cancelled()) {</div>
            <div>        route(ADD_STATUS_ERROR_REASON_TO_HISTORY,
              $(<reply>rs), $(<reply>rr));</div>
            <div>        xlog("L_WARN", "$rU SCRIPT:RADVANCE:WARN: Do
              not route advance replying with $(<reply>rs) -
              $(<reply>rr) \n");</div>
            <div>        $avp(error_reason) := $avp(error_reason) +
              "Call Terminated with " + $(<reply>rs) + ".";</div>
            <div>        t_reply("487","Request cancelled");</div>
            <div>        exit;</div>
            <div>    }</div>
            <div><br>
            </div>
            <div>    if ($(<reply>rs) != null) {</div>
            <div>        route(TRY_CARRIER_FAILOVER, $(<reply>rs),
              $(<reply>rr));</div>
            <div>    } else {</div>
            <div>        $avp(error_reason) := $avp(error_reason) +
              "Server Error V2 - empty response (rs).";</div>
            <div>        route(TRY_CARRIER_FAILOVER, "503", "Server
              Error");</div>
            <div>    }</div>
            <div><br>
            </div>
            <div>    exit;</div>
            <div>}</div>
          </div>
          <div><br>
          </div>
          <div>
            <div>route[TRY_CARRIER_FAILOVER] {</div>
          </div>
          <div>....</div>
          <div>
            <div>   route(RELAY_TO_EGRESS);</div>
            <div>}</div>
          </div>
          <div>}</div>
          <div><br>
          </div>
          <div>Thanks,</div>
          <div>Pat Burke</div>
          <div class="signature">
            <div style="font-family: arial, helvetica, sans-serif;
              font-size: 16px;">
              <br>
              <div><br>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>