<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <tt>Hi Peter,<br>
      <br>
      In TCP, you cannot control the port used to fire a new TCP
      connection - this is selected by the kernel.  Still, the UAS side
      will reply back to the originating port (as the trace shows). The
      fact the uac_registrant does not see the 401 is not necessarily
      because of the TCP connection, but rather because of some SIP
      transactional issue - the reply does not match the requests, so
      the TM  module does not deliver the reply to </tt><tt><tt>uac_registrant.<br>
        <br>
        Do you see any logs from OpenSIPS about the incoming 401 reply ?<br>
        <br>
      </tt>Best 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>

OpenSIPS Summit May 2017 Amsterdam
  <a class="moz-txt-link-freetext" href="http://www.opensips.org/events/Summit-2017Amsterdam.html">http://www.opensips.org/events/Summit-2017Amsterdam.html</a>
</pre>
    <div class="moz-cite-prefix">On 04/21/2017 12:21 PM, Peter Baines
      (lists) wrote:<br>
    </div>
    <blockquote
cite="mid:CADNsZnX-rakqvqSkNMKFYQ60YR3uia9WAVKpZtbqsGqQtV0WEA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>Hi Bogdan,<br>
            <br>
          </div>
          <div>Yes you are correct, it is a retransmission.<br>
            <br>
            I've specifed port 5060 as the forced_socket in the
            registrant table but opensips (1.2.3.4 below) doesn't use
            it. Is there a way to force uac_registrant to use 5060, or
            alternatively make the uac_registrant module listen for
            replies on whatever port it decides to open ?<br>
            <br>
            T 2017/04/21 11:05:26.960562 <a moz-do-not-send="true"
              href="http://1.2.3.4:52945">1.2.3.4:52945</a> -> <a
              moz-do-not-send="true" href="http://4.3.2.1:5060">4.3.2.1:5060</a>
            [AP]<br>
            REGISTER sip:<a moz-do-not-send="true"
              href="http://imsreg.example.com">imsreg.example.com</a>
            SIP/2.0.<br>
            <br>
            T 2017/04/21 11:05:27.381976 <a moz-do-not-send="true"
              href="http://4.3.2.1:5060">4.3.2.1:5060</a> -> <a
              moz-do-not-send="true" href="http://1.2.3.4:52945">1.2.3.4:52945</a>
            [AP]<br>
            SIP/2.0 401 Unauthorized.<br>
          </div>
          <div><br>
            <br>
            mysql> SELECT * FROM registrant \G<br>
            *************************** 1. row
            ***************************<br>
                                id: 1<br>
                         registrar: sip:<a moz-do-not-send="true"
              href="http://imsreg.example.com">imsreg.example.com</a><br>
                             proxy: NULL<br>
                               aor: <a moz-do-not-send="true"
              href="mailto:sip%3A%2B98765432101@ims.example.com">sip:+98765432101@ims.example.com</a><br>
            third_party_registrant: NULL<br>
                          username: +<a moz-do-not-send="true"
              href="mailto:98765432101@ims.example.com">98765432101@ims.example.com</a><br>
                          password: 123<br>
                       binding_URI: <a moz-do-not-send="true"
              href="mailto:sip%3A%2B98765432101@1.2.3.4">sip:+98765432101@1.2.3.4</a><br>
                    binding_params: NULL<br>
                            expiry: NULL<br>
            <b>         forced_socket: tcp:<a moz-do-not-send="true"
                href="http://1.2.3.4:5060">1.2.3.4:5060</a></b><br>
            1 row in set (0.00 sec)<br>
            <br>
          </div>
          <div><br>
          </div>
          Thank you,<br>
        </div>
        Peter<br>
        <div>
          <div>
            <div>
              <div>
                <div class="gmail_extra"><br>
                  <div class="gmail_quote">On 21 April 2017 at 09:53,
                    Bogdan-Andrei Iancu <span dir="ltr"><<a
                        moz-do-not-send="true"
                        href="mailto:bogdan@opensips.org"
                        target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:bogdan@opensips.org">bogdan@opensips.org</a></a>></span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0px
                      0px 0px 0.8ex;border-left:1px solid
                      rgb(204,204,204);padding-left:1ex">
                      <div bgcolor="#FFFFFF"> <tt>Hi Pete,<br>
                          <br>
                          Looking to the logs, I see only one line :<span
                            class="gmail-"><br>
                            <br>
                            Apr 21 09:58:56 dev01
                            /usr/local/opensips_2.2/sbin/<wbr>opensips[4766]:
                            DBG:uac_registrant:reg_tm_<wbr>cback: tm
                            [0x7f2ceb70b2f0] notification cb for
                            FAKED_REPLY [408] reply at [1492761536]<br>
                            <br>
                          </span> The "r</tt><tt><tt>eg_tm_cback" is the
                            TM callback used to report back to the
                            uac_registrant module the reply code for the
                            sent REGISTER. And I see there a 408 timeout
                            :-/ .....<br>
                            <br>
                            Even more, the "run_reg_tm_cback" function
                            (that triggers the build of the auth hdr)
                            does not show up logging anything (and there
                            are some debug over there).<br>
                            <br>
                            So, are you sure that the 401 is actually
                            received ? maybe the second REGISTER is
                            actually a retransmission of the first one ?<br>
                            <br>
                          </tt>Best regards,<br>
                        </tt>
                        <pre class="gmail-m_4641661313998088094moz-signature" cols="72">Bogdan-Andrei Iancu
  OpenSIPS Founder and Developer
  <a moz-do-not-send="true" class="gmail-m_4641661313998088094moz-txt-link-freetext" href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.<wbr>com</a>

OpenSIPS Summit May 2017 Amsterdam
  <a moz-do-not-send="true" class="gmail-m_4641661313998088094moz-txt-link-freetext" href="http://www.opensips.org/events/Summit-2017Amsterdam.html" target="_blank">http://www.opensips.org/<wbr>events/Summit-2017Amsterdam.<wbr>html</a>
</pre><div><div class="gmail-h5">
    <div class="gmail-m_4641661313998088094moz-cite-prefix">On 04/21/2017 11:14 AM, Peter Baines
      (lists) wrote:

    </div>
    </div></div><blockquote type="cite"><div><div class="gmail-h5">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>
                <div>
                  <div>
                    <div>Hello,

                      

                    </div>
                    I am trying to use the uac_registrant module (2.2)
                    to register via TCP but when it recieves the 401 it
                    is not adding the Authorization header.

                    

                  </div>
                  It does work with UDP so I get:

                  

                </div>
                REGISTER -> 401 (with WWW-Authenticate) ->
                REGISTER (with Authorization) -> 200 OK

                

              </div>
              However when I tell it to use TCP it doesn't add the
              Authorization header:

              

              UPDATE registrant SET forced_socket = 'tcp:<a moz-do-not-send="true" href="http://1.2.3.4:5060" target="_blank">1.2.3.4:5060</a>';

              

            </div>
            REGISTER -> 401 (with WWW-Authenticate) -> REGISTER
            (no Authorization) -> 403 Forbidden

            

          </div>
          <div>I've included the debug log for the failing TCP REGSITER
            attempt: <a moz-do-not-send="true" href="https://pastebin.com/gigJkWZX" target="_blank">https://pastebin.com/gigJkWZX</a>

            

          </div>
          Regards,

        </div>
        Peter</div>
      

      <fieldset class="gmail-m_4641661313998088094mimeAttachmentHeader"></fieldset>
      

      </div></div><pre>______________________________<wbr>_________________
Users mailing list
<a moz-do-not-send="true" class="gmail-m_4641661313998088094moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a moz-do-not-send="true" class="gmail-m_4641661313998088094moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-<wbr>bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    

  </div>

</blockquote></div>
</div></div></div></div></div></div>



</blockquote>
</body></html>