<div dir="ltr">Bogdan<div><br></div><div>In fact the TCP connection stays open (I checked with netstat on port 28733 being open on the remote host).</div><div><br></div><div>I think the problem is opensips is opening (or is supposed to open) 5060 on the remote and this is failing? I think it may be looking for an already existing connection to 5060?</div><div><br></div><div>Pete</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 11 February 2015 at 20:11, Bogdan-Andrei Iancu <span dir="ltr">&lt;<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@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 text="#000000" bgcolor="#FFFFFF">
    <div><tt>Hi Pete,<br>
        <br>
        If the TCP connection (the one used to received the SUBSCRIBE
        from end user) went down, when sending an in-dialog NOTIFY,
        OpenSIPS will refuse to open a new TCP connection (the policy is
        to accept connection, not to open connections towards
        end-users).<br>
        <br>
        Can you check if this is your case ?<br>
        <br>
        Regards,<br>
      </tt>
      <pre cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a></pre><div><div class="h5">
      On 11.02.2015 12:50, Pete Kelly wrote:<br>
    </div></div></div>
    <blockquote type="cite"><div><div class="h5">
      <div dir="ltr">
        <div>I have been experimenting recently with Presence over TCP
          and noticed sometimes OpenSIPS fails to send a NOTIFY for a
          recent SUBSCRIBE, with a tcp_send error in the logs.</div>
        <div><br>
        </div>
        <div>I did some research and found an old issue which seems to
          be similar to this as the inbound SUBSCRIBE TCP connection is
          on a high port, yet the NOTIFY is to go to port 5060. </div>
        <div><br>
        </div>
        <div><a href="http://lists.opensips.org/pipermail/users/2013-May/025922.html" target="_blank">http://lists.opensips.org/pipermail/users/2013-May/025922.html</a><br>
        </div>
        <div><br>
        </div>
        <div>The fix here is to set tcp_accept_aliases =1</div>
        <div><br>
        </div>
        <div>I tried this fix and it did not resolve the issue. Looking
          in the source code it seems OpenSIPS may be trying to reuse an
          old/existing TCP connection and is failing to find one - it
          does seem to be slightly intermittent too. Sometimes (very
          rarely) it will work, and it seems to be related to how many
          other TCP connections are open at the moment but I have found
          it very very difficult to pin down. In the end I got round it
          by looping the TCP SUBSCRIBE back to UDP and the OpenSIPS then
          produces a NOTIFY/UDP no problem. This solution is a bodge and
          I would be interested to know if the failure to tcp_send is a
          bug or something I can detect and handle in the config
          somehow?</div>
        <div><br>
        </div>
        <div>Using OpenSIPS 1.11 latest, in EXTRA_DEBUG mode this is the
          error that is produced:</div>
        <div><br>
        </div>
        <div>
          <div>[19361]: ERROR:tm:msg_send: tcp_send failed</div>
          <div>[19361]: ERROR:tm:t_uac: attempt to send to
            &#39;sip:111.111.8.146:5060;transport=tcp;lr&#39; failed</div>
        </div>
        <div><br>
        </div>
        <div>This is the inbound SUBSCRIBE and 200OK... I am simply
          dealing with this by calling handle_subscribe(&#39;1&#39;);</div>
        <div><br>
        </div>
        <div>
          <div>T 2015/02/10 12:52:09.324134 <a href="http://111.111.8.146:28733" target="_blank">111.111.8.146:28733</a>
            -&gt; <a href="http://192.168.0.113:5060" target="_blank">192.168.0.113:5060</a>
            [AP]</div>
          <div>SUBSCRIBE <a href="mailto:sip%3Auser203@test-domain.com" target="_blank">sip:user203@test-domain.com</a>
            SIP/2.0.</div>
          <div>Via: SIP/2.0/TCP
111.111.8.146:5060;egress-zone=DNS;branch=z9hG4bK5c628151ab895c5f2f45ed8bdafeda0d24504147.1569b0b8efc74f7daf3767cc97d0b38e;proxy-call-id=345dee99-7aca-44b4-bf5f-fb1f2e57774a;rport.</div>
          <div>Via: SIP/2.0/TLS
10.15.20.113:54999;branch=z9hG4bKfd5e7b1424014fc8de23205f0de3873e.1;received=188.39.51.2;rport=54999;ingress-zone=DefaultSubZone.</div>
          <div>Call-ID: <a href="mailto:a1922a193e1b6057@10.15.20.113" target="_blank">a1922a193e1b6057@10.15.20.113</a>.</div>
          <div>CSeq: 303 SUBSCRIBE.</div>
          <div>Contact: &lt;<a href="mailto:sip%3Apkelly@test-domain-2.com" target="_blank">sip:pkelly@test-domain-2.com</a>;gr=urn:uuid:683f87a0-e026-5f0a-b86b-58139361c7a4&gt;.</div>
          <div>From: &lt;<a href="mailto:sip%3Apkelly@test-domain-2.com" target="_blank">sip:pkelly@test-domain-2.com</a>&gt;;tag=359dbb1cb104d434.</div>
          <div>To: &lt;<a href="mailto:sip%3Auser203@test-domain.com" target="_blank">sip:user203@test-domain.com</a>&gt;.</div>
          <div>Max-Forwards: 15.</div>
          <div>Record-Route:
            &lt;sip:111.111.8.146:5060;transport=tcp;lr&gt;.</div>
          <div>Record-Route:
            &lt;sip:111.111.8.146:5061;transport=tls;lr&gt;.</div>
          <div>Record-Route:
&lt;sip:188.39.51.2:54999;transport=tls;apparent=remove;ds;lr;proxy-call-id=345dee99-7aca-44b4-bf5f-fb1f2e57774a&gt;.</div>
          <div>User-Agent: Test.</div>
          <div>Expires: 3600.</div>
          <div>Event: presence.</div>
          <div>Accept: application/pidf+xml.</div>
          <div>P-Asserted-Identity: &lt;<a href="mailto:sip%3Apkelly@test-domain-2.com" target="_blank">sip:pkelly@test-domain-2.com</a>&gt;.</div>
          <div>X-TAATag: 6ed63f01-3191-4a1f-b2a2-4121fb834f07.</div>
          <div>Content-Length: 0.</div>
          <div>.</div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>T 2015/02/10 12:52:09.326218 <a href="http://192.168.0.113:5060" target="_blank">192.168.0.113:5060</a>
            -&gt; <a href="http://111.111.8.146:28733" target="_blank">111.111.8.146:28733</a>
            [AP]</div>
          <div>SIP/2.0 200 OK.</div>
          <div>Via: SIP/2.0/TCP
111.111.8.146:5060;received=111.111.8.146;egress-zone=DNS;branch=z9hG4bK5c628151ab895c5f2f45ed8bdafeda0d24504147.1569b0b8efc74f7daf3767cc97d0b38e;proxy-call-id=345dee99-7aca-44b4-bf5f-fb1f2e57774a;rport=28733.</div>
          <div>Via: SIP/2.0/TLS
10.15.20.113:54999;branch=z9hG4bKfd5e7b1424014fc8de23205f0de3873e.1;received=188.39.51.2;rport=54999;ingress-zone=DefaultSubZone.</div>
          <div>Call-ID: <a href="mailto:a1922a193e1b6057@10.15.20.113" target="_blank">a1922a193e1b6057@10.15.20.113</a>.</div>
          <div>CSeq: 303 SUBSCRIBE.</div>
          <div>From: &lt;<a href="mailto:sip%3Apkelly@test-domain-2.com" target="_blank">sip:pkelly@test-domain-2.com</a>&gt;;tag=359dbb1cb104d434.</div>
          <div>To: &lt;<a href="mailto:sip%3Auser203@test-domain.com" target="_blank">sip:user203@test-domain.com</a>&gt;;tag=e3eb1f19b04f8e78afd28f643f416b5f-9be8.</div>
          <div>Record-Route:
            &lt;sip:111.111.8.146:5060;transport=tcp;lr&gt;.</div>
          <div>Record-Route:
            &lt;sip:111.111.8.146:5061;transport=tls;lr&gt;.</div>
          <div>Record-Route:
&lt;sip:188.39.51.2:54999;transport=tls;apparent=remove;ds;lr;proxy-call-id=345dee99-7aca-44b4-bf5f-fb1f2e57774a&gt;.</div>
          <div>Expires: 3600.</div>
          <div>Contact:
            <a href="mailto:sip:sa@222.222.200.79:5060;transport=tcp" target="_blank">&lt;sip:sa@222.222.200.79:5060;transport=tcp&gt;</a>.</div>
          <div>Server: Test.</div>
          <div>Content-Length: 0.</div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
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" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </div>

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