<div dir="ltr"><div class="gmail_extra">Sorry!, after I added the code, opensips does NOT tries to connect. That is my wanted result<br>
<br><div class="gmail_quote">On Mon, Nov 14, 2016 at 2:10 PM, Federico Edorna <span dir="ltr">&lt;<a href="mailto:fedorna@anura.com.ar" target="_blank">fedorna@anura.com.ar</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Right!  Actually I&#39;ve added the code in relay_reply function, not in reply_route, but I guess it has the same effect...<div><br></div><div>Thanks!</div><div><div class="h5"><div class="gmail_extra"><div><div class="m_-5133240261899502599m_-5862465157603142981gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><br></div></div></div>
<br><div class="gmail_quote">On Mon, Nov 14, 2016 at 2:02 PM, Răzvan Crainea <span dir="ltr">&lt;<a href="mailto:razvan@opensips.org" target="_blank">razvan@opensips.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <tt>I got you now: so you are trying to set the tcp_no_new_conn_bflag
      in the reply_route, but OpenSIPS still tries to connect to the
      client?<br>
      After you added the code in reply_received function, OpenSIPS
      still tries to connect?<br>
      <br>
      Best regards,<br>
    </tt><span>
    <pre class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148moz-signature" cols="72">Răzvan Crainea
OpenSIPS Solutions
<a class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148moz-txt-link-abbreviated" href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a></pre>
    </span><div><div class="m_-5133240261899502599m_-5862465157603142981h5"><div class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148moz-cite-prefix">On 11/14/2016 06:06 PM, Federico Edorna
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_extra">Hi Razvan, thanks for your response</div>
        <div class="gmail_extra"><br>
        </div>
        <div class="gmail_extra">I agree that it is dangerous to try to
          open a new tcp connection, that&#39;s why we want to set always
          the flag and never try to open a new tcp connection to the
          UAC.</div>
        <div class="gmail_extra"><br>
        </div>
        <div class="gmail_extra">What I&#39;m trying to say is that
          setting tcp_no_new_conn_bflag doesn&#39;t seem to work for a
          reply, for example what I&#39;ve described in my previous email.
          When opensips receives a reply from the callee (and has to do
          the relay to the caller) but the caller tcp connection has
          gone, opensips will try to open a new connection, even with
          the flag set. It is not a common scenario, but it happens
          sometimes, that the tcp connection is reseted before the call
          is answered.</div>
        <div class="gmail_extra"><br>
        </div>
        <div class="gmail_extra">Maybe I cannot explain the problem in
          my English :(, please let me know...</div>
        <div class="gmail_extra"><br>
        </div>
        <div class="gmail_extra">Best Regards</div>
        <div class="gmail_extra">Federico</div>
        <div class="gmail_extra"> </div>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Mon, Nov 14, 2016 at 11:24 AM,
            Răzvan Crainea <span dir="ltr">&lt;<a href="mailto:razvan@opensips.org" target="_blank">razvan@opensips.org</a>&gt;</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, Federico!<br>
                  <br>
                  Not sure I understand your problem. That flag
                  indicates OpenSIPS to avoid opening a new connection
                  if he doesn&#39;t have one available. Therefore, if the
                  connection to the caller closes between INVITE and 200
                  OK, that flag prevents OpenSIPS from opening a new
                  one.<br>
                  Why would you like to get rid of the TCP SYN message?
                  That happens and the TCP layer, saying that the data
                  arrived successfully. Why would you like to prevent
                  that?<br>
                  <br>
                  Best regards,<br>
                </tt><span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-">
                  <pre class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827moz-signature" cols="72">Răzvan Crainea
OpenSIPS Solutions
<a class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827moz-txt-link-abbreviated" href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a></pre>
                </span>
                <div>
                  <div class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-h5">
                    <div class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827moz-cite-prefix">On
                      11/14/2016 04:05 PM, Federico Edorna wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">Hi Răzvan,
                        <div><br>
                        </div>
                        <div>related to this topic, it seems that
                          tcp_no_new_conn_bflag is not working on
                          &quot;on_reply&quot; routes</div>
                        <div><br>
                        </div>
                        <div>I&#39;ve tried changing modules/tm/t_reply.c
                          (opensips 2.2), using something like this:</div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div>
                          <div>if (tcp_no_new_conn_bflag)</div>
                          <div>                tcp_no_new_conn = 1;</div>
                        </div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div>in &quot;relay_reply&quot; function and now opensips
                          doesn&#39;t try to open a new tcp connection.
                          Without this code I cannot manage to avoid the
                          TCP SYN from opensips to client when receiving
                          a reply and tcp connection is not available.</div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div>Just to clarify, the scenario is something
                          like this:</div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div>
                          <div>A<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                                                        </span>opensips<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                                                        </span>B</div>
                          <div><br>
                          </div>
                          <div>---<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>INVITE<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>---&gt;</div>
                          <div><br>
                          </div>
                          <div><span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                                                                        </span>---<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>INVITE<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                                </span>---&gt;</div>
                          <div><span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                                                                        </span></div>
                          <div><span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                                                                        </span>&lt;---<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>100
                            Trying<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                        </span>---</div>
                          <div><span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                                                                </span></div>
                          <div>&lt;---<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>100
                            Trying<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>---</div>
                          <div><br>
                          </div>
                          <div><span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                                                                        </span>&lt;---<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>183
                            Session Progress---</div>
                          <div><br>
                          </div>
                          <div><br>
                          </div>
                          <div>&lt;---<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>183
                            Session Progress---</div>
                          <div><br>
                          </div>
                          <div><br>
                          </div>
                          <div>--- At this point I wait opensips to
                            close tcp connection
                            (tcp_connection_lifetime=10) and then &quot;B&quot;
                            answers the call ----</div>
                          <div><br>
                          </div>
                          <div><br>
                          </div>
                          <div><span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                                                                        </span>&lt;---<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>200
                            OK<span class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail-Apple-tab-span" style="white-space:pre-wrap">                        </span>---</div>
                        </div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div>Thanks!</div>
                        <div class="gmail_extra"><br clear="all">
                          <div>
                            <div class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827gmail_signature">
                              <div>Federico</div>
                            </div>
                          </div>
                          <br>
                          <div class="gmail_quote">On Thu, Oct 27, 2016
                            at 4:58 AM, Răzvan Crainea <span dir="ltr">&lt;<a href="mailto:razvan@opensips.org" target="_blank">razvan@opensips.org</a>&gt;</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, Rodrigo!<br>
                                  <br>
                                  Having OpenSIPS opening TCP
                                  connections towards client is a bit
                                  dangerous, especially if the clients
                                  are behind NAT. That&#39;s because most
                                  likely you will not be able to reach
                                  them, and opensips will get stuck
                                  trying to connect (until it triggers a
                                  timeout). That&#39;s why the best way to
                                  go is to try to keep the connection
                                  (ideally opened by the client at
                                  REGISTER) as much as possible. This is
                                  usually done by pinging (as discussed
                                  in a previous email). So my suggestion
                                  is to try to avoid opening new TCP
                                  connections with clients, unless you
                                  really know they will always be
                                  reachable.<br>
                                  <br>
                                  The behavior you are describing
                                  (INVITE vs BYE handling), might be
                                  related to the fact that you are
                                  setting the tcp_no_new_conn_bflag[1]
                                  flag for BYE messages, but not for
                                  INVITEs. Is this correct? If not, do
                                  you see any errors in the script?<br>
                                  <br>
                                  [1] <a class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094moz-txt-link-freetext" href="http://www.opensips.org/Documentation/Script-CoreParameters-2-2#toc101" target="_blank">http://www.opensips.org/Docume<wbr>ntation/Script-CoreParameters-<wbr>2-2#toc101</a><br>
                                </tt>
                                <pre class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094moz-signature" cols="72">Răzvan Crainea
OpenSIPS Solutions
<a class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094moz-txt-link-abbreviated" href="http://www.opensips-solutions.com" target="_blank">www.opensips-solutions.com</a></pre>
                                <div>
                                  <div class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827h5">
                                    <div class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094moz-cite-prefix">On
                                      10/26/2016 10:59 PM, Rodrigo
                                      Pimenta Carvalho wrote:<br>
                                    </div>
                                  </div>
                                </div>
                                <blockquote type="cite">
                                  <div>
                                    <div class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827h5">
                                      <div id="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:calibri,arial,helvetica,sans-serif">
                                        <p>Hi.</p>
                                        <p><br>
                                        </p>
                                        <p>After some log debug I have
                                          observed the following
                                          behavior in the OpenSISP
                                          (2.2.1):</p>
                                        <p><br>
                                        </p>
                                        <p>When OpenSIPS has to send a
                                          SIP INVITE to a peer through a
                                          TCP connection that was closed
                                          before by some way, OpenSIPS
                                          open a new one and then sends
                                          the SIP message to the peer
                                          successfully.</p>
                                        <p><br>
                                        </p>
                                        <p>However, <span>when OpenSIPS
                                            has to send a SIP BYE to a
                                            peer through a TCP
                                            connection that was closed
                                            before, OpenSIPS open a new
                                            one, but doesn&#39;t send the
                                            SIP BYE. In this case SIP
                                            BYE is discarded.</span></p>
                                        <p><span><br>
                                          </span></p>
                                        <p><span>How to change the
                                            behavior of OpenSIPS to make
                                            it to send the SIP BYE is
                                            such case?</span></p>
                                        <p><span><br>
                                          </span></p>
                                        <p><span>I&#39;m looking for ways of
                                            fix or workaround of a TCP
                                            tear down connection that
                                            happens during dialogs.<br>
                                          </span></p>
                                        <p><span><br>
                                          </span></p>
                                        <p><span>Any hint will be very
                                            helpful!<br>
                                          </span></p>
                                        <p><br>
                                        </p>
                                        <div id="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094Signature">
                                          <div name="divtagdefaultwrapper">
                                            <div class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094BodyFragment"><font size="2">
                                                <div class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094PlainText">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="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094mimeAttachmentHeader"></fieldset>
                                      <br>
                                    </div>
                                  </div>
                                  <pre>______________________________<wbr>_________________
Users mailing list
<a class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827m_-2659467867638395094moz-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>


______________________________<wbr>_________________

Users mailing list

<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>

<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-<wbr>bin/mailman/listinfo/users</a>


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


<fieldset class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827mimeAttachmentHeader"></fieldset>
<pre>______________________________<wbr>_________________
Users mailing list
<a class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148gmail-m_-3105548140052468827moz-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></div></div>
______________________________<wbr>_________________

Users mailing list

<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>

<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-<wbr>bin/mailman/listinfo/users</a>


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


<fieldset class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148mimeAttachmentHeader"></fieldset>
<pre>______________________________<wbr>_________________
Users mailing list
<a class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a class="m_-5133240261899502599m_-5862465157603142981m_597666649502895148moz-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></div></div><br>______________________________<wbr>_________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-<wbr>bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div>