<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <tt>Hi, Rodrigo!<br>
      <br>
      See my answers inline.<br>
      <br>
      BR<br>
    </tt>
    <pre class="moz-signature" cols="72">Răzvan Crainea
OpenSIPS Solutions
<a class="moz-txt-link-abbreviated" href="http://www.opensips-solutions.com">www.opensips-solutions.com</a></pre>
    <div class="moz-cite-prefix">On 10/26/2016 08:15 PM, Rodrigo Pimenta
      Carvalho wrote:<br>
    </div>
    <blockquote
cite="mid:BN6PR02MB27217093D9A82170A9651787B5AB0@BN6PR02MB2721.namprd02.prod.outlook.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <p>Hi Răzvan.</p>
        <p><br>
        </p>
        <p>Thank you very much.</p>
        <p>I'm facing a problem here related to TCP connection teared
          down during dialogs.</p>
        <p>While a peer is not in dialogs, its TCP connection to
          OpenSIPS keeps online all the time.</p>
        <p>However, when such peer enters in a conversation (be part of
          a dialog), after few minutes there is a EOF received in a
          socket. After this, OpenSIPS can no more send SIP BYEs to the
          respective peer. In the log I can see:</p>
        <p><br>
        </p>
        <div><span style="font-size: 10pt; color: rgb(0, 111, 201);">Jan
            02 01:38:45 colibri-imx6-jfl opensips[21018]: Jan  2
            01:38:45 [21027] DBG:core:tcp_read: EOF on 0x74e3d048, FD
            24                                                                  
             </span><br>
          <span style="font-size: 10pt; color: rgb(0, 111, 201);">Jan 02
            01:38:45 colibri-imx6-jfl opensips[21018]: Jan  2 01:38:45
            [21027] DBG:core:tcp_read_req: EOF
received                                                                          
             </span><br>
          <span style="font-size: 10pt; color: rgb(0, 111, 201);">Jan 02
            01:38:45 colibri-imx6-jfl opensips[21018]: Jan  2 01:38:45
            [21027] DBG:core:io_watch_del: [TCP_worker] io_watch_del op
            on index 0 24 (0x1875e8, 24, 0, 0x10,0x3) fd_no=3 called   </span><br>
          <span style="font-size: 10pt; color: rgb(0, 111, 201);">Jan 02
            01:38:45 colibri-imx6-jfl opensips[21018]: Jan  2 01:38:45
            [21027] DBG:core:tcpconn_release:  releasing con 0x74e3d048,
            state -1, fd=-1, id=3  
          </span><br>
          <span style="font-size: 10pt; color: rgb(0, 111, 201);">Jan 02
            01:38:45 colibri-imx6-jfl opensips[21018]: Jan  2 01:38:45
            [21027] DBG:core:tcpconn_release:  extra_data
            (nil)                                                                  
             </span><br>
          <span style="font-size: 10pt; color: rgb(0, 111, 201);">Jan 02
            01:38:45 colibri-imx6-jfl opensips[21018]: Jan  2 01:38:45
            [21029] DBG:core:handle_tcp_worker: reader response=
            74e3d048, -1 from
            2                                               </span><br>
          <span style="font-size: 10pt; color: rgb(0, 111, 201);">Jan 02
            01:38:45 colibri-imx6-jfl opensips[21018]: Jan  2 01:38:45
            [21029] DBG:core:tcpconn_destroy: destroying connection
            0x74e3d048, flags 0006  </span></div>
        <br>
        <p>...</p>
        <p>When OpenSIPS try to send a SIP BYE via socket <span
            style="font-size: 10pt; color: rgb(0, 111, 201);">
            0x74e3d048</span> , I can see the log:<br>
        </p>
        <p><span style="font-size: 10pt; color: rgb(0, 111, 201);">Jan
            02 01:40:49 colibri-imx6-jfl opensips[21018]: Jan  2
            01:40:49 [21026] DBG:core:proto_tcp_send: no open tcp
            connection found, opening new one, async = 1</span></p>
        <p><br>
        </p>
        <p>I have already used the flag "Pp" in the creation of dialogs,
          but it didn't take effect. That is, even with "Pp" I'm still
          getting "EOF" in the TCP socket.</p>
        <p><br>
        </p>
        <p>1 - Should the flag "Pp" avoid those EOFs during dialogs?</p>
      </div>
    </blockquote>
    Ideally, it should. However if the client does not "like" the
    pinging and closes the connection, there's not that much we can do.<br>
    <blockquote
cite="mid:BN6PR02MB27217093D9A82170A9651787B5AB0@BN6PR02MB2721.namprd02.prod.outlook.com"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <p><br>
        </p>
        <p>That flag causes the OpenSIPS to send SIP OPTIONS. The peers
          are replying with SIP 500.
          <br>
        </p>
      </div>
    </blockquote>
    That's not really an issue. The SIP OPTIONs pinging has two
    purposes: 1. verify if the dialog is still active, and 2. keep the
    NAT pinhole open. If the SIP client doesn't know how to reply to
    in-dialog pinging, then 1. isn't really useful. So the reply code
    doesn't really matter, unless it is a 408, which means that the peer
    did not respond at all, and the dialog will be turn down.<br>
    <blockquote
cite="mid:BN6PR02MB27217093D9A82170A9651787B5AB0@BN6PR02MB2721.namprd02.prod.outlook.com"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <p>
        </p>
        <p><br>
        </p>
        <p>2- Is a SIP 500 reply enough to OpenSIPS keep the dialog
          connected?</p>
      </div>
    </blockquote>
    Any communication between OpenSIPS and the client keeps the NAT
    pinhole open (see 2. above). From SIP perspective, that 500 could
    have a lot of meanings: the client does not know how to reply, or
    there was an internal error that could not process the message.
    However, this whole communication will keep the connection alive.<br>
    <blockquote
cite="mid:BN6PR02MB27217093D9A82170A9651787B5AB0@BN6PR02MB2721.namprd02.prod.outlook.com"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <p><br>
        </p>
        <p>3 - Does it make sense getting <span>absence</span> of keep
          alive messages during dialogs?</p>
      </div>
    </blockquote>
    So as I said above, any pinging method is useful to keep the
    connection alive. Regarding the dialogs, there is no special need
    for pinging from SIP perspective, unless you are using SST, which I
    presume you are not.<br>
    <blockquote
cite="mid:BN6PR02MB27217093D9A82170A9651787B5AB0@BN6PR02MB2721.namprd02.prod.outlook.com"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <p><br>
        </p>
        <p>Any hint will be very helpful!</p>
        <p>P.S.: I will check the TCP trace too, looking for keep
          alives. <br>
        </p>
      </div>
    </blockquote>
    From your diagnosis, I understand that the client closes the
    connection, right? Unfortunately I don't know why it does that,
    perhaps the best thing to do is to check the client's logs.<br>
    <blockquote
cite="mid:BN6PR02MB27217093D9A82170A9651787B5AB0@BN6PR02MB2721.namprd02.prod.outlook.com"
      type="cite">
      <div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;">
        <p><br>
        </p>
        <p>Best regards.<br>
        </p>
        <p><br>
        </p>
        <p><br>
        </p>
        <div id="Signature">
          <div name="divtagdefaultwrapper"
            style="font-family:Calibri,Arial,Helvetica,sans-serif;
            font-size:; margin:0">
            <div class="BodyFragment"><font size="2">
                <div class="PlainText">RODRIGO PIMENTA CARVALHO<br>
                  Inatel Competence Center<br>
                  Software<br>
                  Ph: +55 35 3471 9200 RAMAL 979<br>
                </div>
              </font></div>
          </div>
        </div>
        <br>
        <br>
        <div style="color: rgb(0, 0, 0);">
          <hr tabindex="-1" style="display:inline-block; width:98%">
          <div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
              color="#000000" face="Calibri, sans-serif"><b>De:</b>
              <a class="moz-txt-link-abbreviated" href="mailto:users-bounces@lists.opensips.org">users-bounces@lists.opensips.org</a>
              <a class="moz-txt-link-rfc2396E" href="mailto:users-bounces@lists.opensips.org">&lt;users-bounces@lists.opensips.org&gt;</a> em nome de Răzvan
              Crainea <a class="moz-txt-link-rfc2396E" href="mailto:razvan@opensips.org">&lt;razvan@opensips.org&gt;</a><br>
              <b>Enviado:</b> quarta-feira, 26 de outubro de 2016 13:08<br>
              <b>Para:</b> <a class="moz-txt-link-abbreviated" href="mailto:users@lists.opensips.org">users@lists.opensips.org</a><br>
              <b>Assunto:</b> Re: [OpenSIPS-Users] Is it a kind of TCP
              keep alive produced by OpenSIPS?</font>
            <div> </div>
          </div>
          <div><tt>Hi, Rodrigo!<br>
              <br>
              The logs you are tracing are printed when OpenSIPS
              receives something from the client, and then immediately
              responds back. Due to the fact that we don't see any other
              debug messages, like SIP parsing &amp; stuff, makes me
              think that it is a CRLF pinging - the client periodically
              sends a CRLFCRLF TCP message to OpenSIPS, and OpenSIPS
              responds with a single CRLF. Note that this is different
              from a TCP keep-alive, where each peer send a 0-length TCP
              message, without any body. That message doesn't even get
              to the application layer.<br>
              However, tracing the communication between OpenSIPS and
              the client should confirm the above :).<br>
              <br>
              Best regards,<br>
            </tt>
            <pre class="moz-signature" cols="72">Răzvan Crainea
OpenSIPS Solutions
<a moz-do-not-send="true" previewremoved="true" id="LPlnk872928" class="moz-txt-link-abbreviated" href="http://www.opensips-solutions.com">www.opensips-solutions.com</a></pre>
            <div style="margin-bottom: 20px; overflow: auto; width:
              100%; text-indent: 0px;"
              id="LPBorder_GT_14774896262840.7749040558889541">
              <table style="width: 90%; background-color: rgb(255, 255,
                255); position: relative; overflow: auto; padding-top:
                20px; padding-bottom: 20px; margin-top: 20px;
                border-top: 1px dotted rgb(200, 200, 200);
                border-bottom: 1px dotted rgb(200, 200, 200);"
                id="LPContainer_14774896262790.8131331098353491"
                cellspacing="0">
                <tbody>
                  <tr style="border-spacing: 0px;" valign="top">
                    <td colspan="2" style="vertical-align: top;
                      position: relative; padding: 0px; display:
                      table-cell;"
                      id="TextCell_14774896262810.25225818451243276">
                      <div style="top: 0px; color: rgb(0, 120, 215);
                        font-weight: 400; font-size: 21px; font-family:
                        &quot;wf_segoe-ui_light&quot;,&quot;Segoe UI
                        Light&quot;,&quot;Segoe WP
                        Light&quot;,&quot;Segoe UI&quot;,&quot;Segoe
                        WP&quot;,Tahoma,Arial,sans-serif; line-height:
                        21px;"
                        id="LPTitle_14774896262810.20247837430869875">
                        <a moz-do-not-send="true" target="_blank"
                          href="http://www.opensips-solutions.com/"
                          style="text-decoration: none;"
                          id="LPUrlAnchor_14774896262820.020496668580710642">Home
                          — OpenSIPS Solutions</a></div>
                      <div style="margin: 10px 0px 16px; color: rgb(102,
                        102, 102); font-weight: 400; font-family:
                        &quot;wf_segoe-ui_normal&quot;,&quot;Segoe
                        UI&quot;,&quot;Segoe
                        WP&quot;,Tahoma,Arial,sans-serif; font-size:
                        14px; line-height: 14px;"
                        id="LPMetadata_14774896262820.29194839532997063">
                        <a class="moz-txt-link-abbreviated" href="http://www.opensips-solutions.com">www.opensips-solutions.com</a></div>
                      <div style="display: block; color: rgb(102, 102,
                        102); font-weight: 400; font-family:
                        &quot;wf_segoe-ui_normal&quot;,&quot;Segoe
                        UI&quot;,&quot;Segoe
                        WP&quot;,Tahoma,Arial,sans-serif; font-size:
                        14px; line-height: 20px; max-height: 100px;
                        overflow: hidden;"
                        id="LPDescription_14774896262830.7344774807265421">
                        OpenSIPS is a mature Open Source implementation
                        of a SIP server. OpenSIPS is more than a SIP
                        proxy/router as it includes application-level
                        functionalities.</div>
                    </td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div class="moz-cite-prefix">On 10/26/2016 05:10 PM, Rodrigo
              Pimenta Carvalho wrote:<br>
            </div>
            <blockquote type="cite">
              <div id="divtagdefaultwrapper" style="font-size:12pt;
                color:#000000;
                font-family:Calibri,Arial,Helvetica,sans-serif">
                <p>Dear OpenSIPS users,<br>
                </p>
                <p><br>
                </p>
                <p>In the OpenSIPS log I see:<br>
                </p>
                <p><br>
                </p>
                <div>Jan 01 19:30:38 colibri-imx6-jfl opensips[3444]:
                  Jan  1 19:30:38 [3451] DBG:core:tcp_read_req: Using
                  the global ( per process ) buff<br>
                  Jan 01 19:30:38 colibri-imx6-jfl opensips[3444]: Jan 
                  1 19:30:38 [3451] DBG:core:tcp_handle_req:
                  content-length= 0<br>
                  Jan 01 19:30:38 colibri-imx6-jfl opensips[3444]: Jan 
                  1 19:30:38 [3451] DBG:core:async_tsend_stream: Async
                  successful write from first try on 0x74e13548<br>
                  Jan 01 19:30:38 colibri-imx6-jfl opensips[3444]: Jan 
                  1 19:30:38 [3451] DBG:core:tcp_read_req: tcp_read_req
                  end<br>
                  <br>
                  The frequency is 1 time at each 1,5 minute. There is
                  only one client online. I suspect that OpenSIPS uses
                  the socket
                  <span>0x74e13548</span> to send messages to such
                  client. The client became online using TCP.<br>
                  <br>
                  Just to confirm, is this log a result of a TCP keep
                  alive function enabled?<br>
                  <br>
                  Best regards.<br>
                  <br>
                  <br>
                </div>
                <p><br>
                </p>
                <p><br>
                </p>
                <div id="Signature">
                  <div name="divtagdefaultwrapper"
                    style="font-family:Calibri,Arial,Helvetica,sans-serif;
                    font-size:; margin:0">
                    <div class="BodyFragment"><font size="2">
                        <div class="PlainText">RODRIGO PIMENTA CARVALHO<br>
                          Inatel Competence Center<br>
                          Software<br>
                          Ph: +55 35 3471 9200 RAMAL 979<br>
                        </div>
                      </font></div>
                  </div>
                </div>
              </div>
              <br>
              <fieldset class="mimeAttachmentHeader"></fieldset>
              <br>
              <pre>_______________________________________________
Users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a moz-do-not-send="true" 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>
          </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>