<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">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">111.111.8.146:28733</a> -&gt; <a href="http://192.168.0.113:5060">192.168.0.113:5060</a> [AP]</div><div>SUBSCRIBE <a href="mailto:sip%3Auser203@test-domain.com">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">a1922a193e1b6057@10.15.20.113</a>.</div><div>CSeq: 303 SUBSCRIBE.</div><div>Contact: &lt;<a href="mailto:sip%3Apkelly@test-domain-2.com">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">sip:pkelly@test-domain-2.com</a>&gt;;tag=359dbb1cb104d434.</div><div>To: &lt;<a href="mailto:sip%3Auser203@test-domain.com">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">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">192.168.0.113:5060</a> -&gt; <a href="http://111.111.8.146:28733">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">a1922a193e1b6057@10.15.20.113</a>.</div><div>CSeq: 303 SUBSCRIBE.</div><div>From: &lt;<a href="mailto:sip%3Apkelly@test-domain-2.com">sip:pkelly@test-domain-2.com</a>&gt;;tag=359dbb1cb104d434.</div><div>To: &lt;<a href="mailto:sip%3Auser203@test-domain.com">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: &lt;sip:sa@222.222.200.79:5060;transport=tcp&gt;.</div><div>Server: Test.</div><div>Content-Length: 0.</div></div></div>