<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>there is an option that you can set to reuse the port for tcp/tls
      connections, but even so it is a best effort and it is not going
      to ensured -- all these are practically flags set to the sockets
      and the kernel (tcp stack) decides after all.</p>
    <p>Anyhow, the rport is mainly useful for connectionless
      communication, like UDP. For tcp/tls, the SIP specs demand to
      reuse the existing connections. As I did several Kamailio-MSTeams
      interconnectivity deployments, I can tell that the source port was
      never a problem. The TLS connection is kept open and MSTeams sends
      back traffic on it.<br>
    </p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 08.01.21 14:32, Charles Phillips
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:FCF97D62-9C6E-4B01-9240-93A665EB5D41@rustybike.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      Thanks for the quick response Joel.  Yes, I have read the article
      and I have tested and confirmed that I am correctly appending the
      contact header (I probably should have left that in the snippet
      for clarity).  Below is an example of Kamailio setting up the
      connection.  It is going out port 46245 this time, but it is
      random.
      <div class="">
        <div class="">
          <div class=""><br class="">
          </div>
          <div class="">
            <div class="">07:59:23.572319 IP *my.kamailio.server*.46245
              > *ms.teams.server*.sip-tls: Flags [P.], seq 1:518, ack
              1, win 502, length 517</div>
            <div class="">07:59:23.802458 IP *ms.teams.server*.sip-tls
              > *my.kamailio.server*.46245: Flags [P.], seq 1:3767,
              ack 518, win 2051, length 3766</div>
            <div class=""><br class="">
            </div>
            <div class="">The TLS connection shows as successful in the
              logs.</div>
            <div class=""><br class="">
            </div>
            <div class="">
              <div style="color: rgb(0, 0, 0); font-family: Helvetica;
                font-size: 12px; font-style: normal; font-variant:
                normal; font-weight: normal; letter-spacing: normal;
                orphans: auto; text-align: start; text-indent: 0px;
                text-transform: none; white-space: normal; widows: auto;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                word-wrap: break-word; -webkit-nbsp-mode: space;
                -webkit-line-break: after-white-space;" class="">
                <div class=""><br class="Apple-interchange-newline">
                  - Charles </div>
                <div class=""><br class="">
                </div>
                <div class=""><br class="">
                </div>
              </div>
              Date: Thu, 7 Jan 2021 19:12:10 -0800<br class="">
              From: Joel Serrano <<a href="mailto:joel@textplus.com"
                class="" moz-do-not-send="true">joel@textplus.com</a>><br
                class="">
              To: "Kamailio (SER) - Users Mailing List"<br class="">
              <span class="Apple-tab-span" style="white-space: pre;"> </span><<a
                href="mailto:sr-users@lists.kamailio.org" class=""
                moz-do-not-send="true">sr-users@lists.kamailio.org</a>><br
                class="">
              Subject: Re: [SR-Users] Source Port on TLS OPTIONS from
              Dispatcher<br class="">
              Message-ID:<br class="">
              <span class="Apple-tab-span" style="white-space: pre;"> </span><<a
href="mailto:CAMtXxQnLtEyD=40cwKembxiyj3D778eK=+5JD7sL4CvYbYXF1g@mail.gmail.com"
                class="" moz-do-not-send="true">CAMtXxQnLtEyD=40cwKembxiyj3D778eK=+5JD7sL4CvYbYXF1g@mail.gmail.com</a>><br
                class="">
              Content-Type: text/plain; charset="utf-8"<br class="">
              <br class="">
              Hi Charles,<br class="">
              <br class="">
              I don't think your issue is rport, make sure you are
              setting the Contact<br class="">
              header correctly.<br class="">
              <br class="">
              Have you checked this blog post:<br class="">
              <a href="https://skalatan.de/en/blog/kamailio-sbc-teams"
                class="" moz-do-not-send="true">https://skalatan.de/en/blog/kamailio-sbc-teams</a> ?<br
                class="">
              <br class="">
              There is a specific section that talks about how to tell
              Kamailio to send<br class="">
              the OPTIONS like MS Teams wants them.<br class="">
              <br class="">
              Good luck,<br class="">
              Joel.<br class="">
              <br class="Apple-interchange-newline">
            </div>
            <div><br class="">
              <blockquote type="cite" class="">
                <div class="">On Jan 7, 2021, at 7:31 PM, Charles
                  Phillips <<a href="mailto:charles@rustybike.com"
                    class="" moz-do-not-send="true">charles@rustybike.com</a>>
                  wrote:</div>
                <br class="Apple-interchange-newline">
                <div class="">
                  <meta http-equiv="Content-Type" content="text/html;
                    charset=UTF-8" class="">
                  <div style="word-wrap: break-word; -webkit-nbsp-mode:
                    space; line-break: after-white-space;" class="">
                    <div class="">
                      <div style="font-family: Helvetica; font-size:
                        12px; font-style: normal;
                        font-variant-ligatures: normal;
                        font-variant-caps: normal;
                        font-variant-east-asian: normal;
                        font-variant-position: normal; font-weight:
                        normal; letter-spacing: normal; text-align:
                        start; text-indent: 0px; text-transform: none;
                        white-space: normal; word-spacing: 0px;
                        -webkit-text-stroke-width: 0px; word-wrap:
                        break-word; -webkit-nbsp-mode: space;
                        line-break: after-white-space;" class="">Hello
                        all.  As they say in radio, “long time listener,
                        first time caller”</div>
                      <div style="font-family: Helvetica; font-size:
                        12px; font-style: normal;
                        font-variant-ligatures: normal;
                        font-variant-caps: normal;
                        font-variant-east-asian: normal;
                        font-variant-position: normal; font-weight:
                        normal; letter-spacing: normal; text-align:
                        start; text-indent: 0px; text-transform: none;
                        white-space: normal; word-spacing: 0px;
                        -webkit-text-stroke-width: 0px; word-wrap:
                        break-word; -webkit-nbsp-mode: space;
                        line-break: after-white-space;" class=""><br
                          class="">
                      </div>
                      <div style="font-family: Helvetica; font-size:
                        12px; font-style: normal;
                        font-variant-ligatures: normal;
                        font-variant-caps: normal;
                        font-variant-east-asian: normal;
                        font-variant-position: normal; font-weight:
                        normal; letter-spacing: normal; text-align:
                        start; text-indent: 0px; text-transform: none;
                        white-space: normal; word-spacing: 0px;
                        -webkit-text-stroke-width: 0px; word-wrap:
                        break-word; -webkit-nbsp-mode: space;
                        line-break: after-white-space;" class="">Anyway,
                        I am having trouble getting past the following
                        road block and any help would be greatly
                        appreciated.</div>
                      <div style="font-family: Helvetica; font-size:
                        12px; font-style: normal;
                        font-variant-ligatures: normal;
                        font-variant-caps: normal;
                        font-variant-east-asian: normal;
                        font-variant-position: normal; font-weight:
                        normal; letter-spacing: normal; text-align:
                        start; text-indent: 0px; text-transform: none;
                        white-space: normal; word-spacing: 0px;
                        -webkit-text-stroke-width: 0px; word-wrap:
                        break-word; -webkit-nbsp-mode: space;
                        line-break: after-white-space;" class=""><br
                          class="">
                      </div>
                      <div style="font-family: Helvetica; font-size:
                        12px; font-style: normal;
                        font-variant-ligatures: normal;
                        font-variant-caps: normal;
                        font-variant-east-asian: normal;
                        font-variant-position: normal; font-weight:
                        normal; letter-spacing: normal; text-align:
                        start; text-indent: 0px; text-transform: none;
                        white-space: normal; word-spacing: 0px;
                        -webkit-text-stroke-width: 0px; word-wrap:
                        break-word; -webkit-nbsp-mode: space;
                        line-break: after-white-space;" class="">Kamailio
                        version is 5.4.3 </div>
                      <div style="font-family: Helvetica; font-size:
                        12px; font-style: normal;
                        font-variant-ligatures: normal;
                        font-variant-caps: normal;
                        font-variant-east-asian: normal;
                        font-variant-position: normal; font-weight:
                        normal; letter-spacing: normal; text-align:
                        start; text-indent: 0px; text-transform: none;
                        white-space: normal; word-spacing: 0px;
                        -webkit-text-stroke-width: 0px; word-wrap:
                        break-word; -webkit-nbsp-mode: space;
                        line-break: after-white-space;" class=""><br
                          class="">
                      </div>
                      <div style="font-variant-ligatures: normal;
                        font-variant-east-asian: normal;
                        font-variant-position: normal; text-align:
                        start; text-indent: 0px; word-wrap: break-word;
                        -webkit-nbsp-mode: space; line-break:
                        after-white-space;" class="">When attempting to
                        use dispatcher to send OPTIONS packets to
                        several TLS destinations, the packets are
                        leaving the Kamailio server on random ports.
                         This is a problem because the servers I am
                        sending the OPTIONS to (MS Teams) are enforcing
                        rport so the responses are returned to a port
                        that Kamailio is not listening on.  I have tried
                        to force the socket in the event route (relevant
                        parts of snippet below) but it does not appear
                        to help.  I should also mention that I am not
                        behind NAT and the TLS socket is specified in
                        the dispatcher attrs. </div>
                      <div style="font-variant-ligatures: normal;
                        font-variant-east-asian: normal;
                        font-variant-position: normal; text-align:
                        start; text-indent: 0px; word-wrap: break-word;
                        -webkit-nbsp-mode: space; line-break:
                        after-white-space;" class="">
                        <div style="font-family: Helvetica; font-size:
                          12px; font-style: normal; font-variant-caps:
                          normal; font-weight: normal; letter-spacing:
                          normal; text-transform: none; white-space:
                          normal; word-spacing: 0px;
                          -webkit-text-stroke-width: 0px;" class=""><br
                            class="">
                        </div>
                        <div class="">event_route[tm:local-request] {<br
                            class="">
                              sip_trace();</div>
                        <div class=""><br class="">
                        </div>
                        <div class=""><br class="">
                              $fs = “tls:**ip-address**:5061”;</div>
                        <div class=""><br class="">
                        </div>
                        <div class=""><br class="">
                          }</div>
                      </div>
                    </div>
                    <div class=""><br class="">
                    </div>
                    <div class="">I have used Kamailio as a TLS server
                      for many projects, but this is my first time as a
                      client.  I am sure I am missing something.</div>
                    <div class="">
                      <div style="font-family: Helvetica; font-size:
                        12px; font-style: normal;
                        font-variant-ligatures: normal;
                        font-variant-caps: normal;
                        font-variant-east-asian: normal;
                        font-variant-position: normal; font-weight:
                        normal; letter-spacing: normal; text-align:
                        start; text-indent: 0px; text-transform: none;
                        white-space: normal; word-spacing: 0px;
                        -webkit-text-stroke-width: 0px; word-wrap:
                        break-word; -webkit-nbsp-mode: space;
                        line-break: after-white-space;" class="">
                        <div class=""><br
                            class="Apple-interchange-newline">
                          - Charles</div>
                        <div class=""><br class="">
                        </div>
                      </div>
                      <br class="Apple-interchange-newline"
                        style="font-family: Helvetica; font-size: 12px;
                        font-style: normal; font-variant-ligatures:
                        normal; font-variant-caps: normal;
                        font-variant-east-asian: normal;
                        font-variant-position: normal; font-weight:
                        normal; letter-spacing: normal; text-align:
                        start; text-indent: 0px; text-transform: none;
                        white-space: normal; word-spacing: 0px;
                        -webkit-text-stroke-width: 0px;">
                      <br class="Apple-interchange-newline">
                    </div>
                    <br class="">
                  </div>
                </div>
              </blockquote>
            </div>
            <br class="">
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<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>
Funding: <a class="moz-txt-link-freetext" href="https://www.paypal.me/dcmierla">https://www.paypal.me/dcmierla</a></pre>
  </body>
</html>