<p>Just a questions on how to do this properly. The configuration below works if I dial the number like <a href="mailto:+18888888888@sip.ca.didlogic.net">+18888888888@sip.ca.didlogic.net</a> (thats the gateway). But it fails with below log if I try to dial it like <a href="mailto:+18888888888@mykamailioserver.com">+18888888888@mykamailioserver.com</a>. I'm trying to get the kamailio to rewrite the request URI so the user doesn't have to type in the gateway. So the users just need to type in the phone number, but for some reason it's not working, any ideas what i'm doing wrong?.</p>

<p>Thanks again in advance!</p>

<pre><code>Feb 12 01:18:38 sipr /usr/local/sbin/kamailio[24307]: INFO: <script>: Request coming from WS
Feb 12 01:18:38 sipr /usr/local/sbin/kamailio[24307]: ERROR: tm [t_fwd.c:755]: add_uac(): ERROR: add_uac: maximum number of branches exceeded
Feb 12 01:18:38 sipr /usr/local/sbin/kamailio[24307]: ERROR: tm [t_fwd.c:1711]: t_forward_nonack(): ERROR: t_forward_nonack: failure to add branches
Feb 12 01:18:38 sipr /usr/local/sbin/kamailio[24307]: ERROR: tm [tm.c:1466]: _w_t_relay_to(): ERROR: w_t_relay_to: t_relay_to failed
Feb 12 01:18:38 sipr /usr/local/sbin/kamailio[24307]: ERROR: <script>: RELAY -> !t_relay
Feb 12 01:18:38 sipr /usr/local/sbin/kamailio[24307]: ERROR: sl [sl_funcs.c:363]: sl_reply_error(): ERROR: sl_reply_error used: I'm terribly sorry, server error occurred (1/SL)
</code></pre>

<pre><code>route[RELAY] {
  if (is_method("INVITE")) {
    dlg_manage();
    route(SETUP_BY_TRANSPORT);
    if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");
  }

  t_set_disable_internal_reply(1); # turn off sending internal reply on error
  rewritehostport("sip.ca.didlogic.net:5060");
  if (!t_relay()) {
    xlog("RELAY -> !t_relay");
    sl_reply_error();
  }
  exit;
}
</code></pre>

<pre><code>failure_route[MANAGE_FAILURE] {

   xlog("DEBUG: MANAGE FAILURE ROUTE: ");

   if ($T_reply_code == "407")  # there's also 401
    {

        $avp(arealm) = GATEWAY;
        $avp(auser) = USERNAME;
        $avp(apass) = PASSWORD;

        uac_auth();

        rtpengine_offer("force trust-address replace-origin replace-session-connection ICE=remove RTP/AVP");
        route(NATMANAGE);
        route(RELAY);
        exit;
    }
}
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/issues/507">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZWOvI1b168-SBh03qsYOKsDFaqplks5pjXMvgaJpZM4HYzbx.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/507"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>