<div dir="ltr">thank you all for your answers. As I want to implement it using only java and tcp I think using session heartbeat with a monitoring timer is my best solution.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 5, 2015 at 3:21 PM, Regis M <span dir="ltr">&lt;<a href="mailto:regis.freeswitch.org@tornad.net" target="_blank">regis.freeswitch.org@tornad.net</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">As Stanislas said.. in TCP, broken socket is detected by client only if server closes it properly or client is trying to sending something on closed/died server socket.... I think in nodejs, an open connection will wait forever too if not sending anything.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-08-05 12:35 GMT+02:00 Danny Gershman <span dir="ltr">&lt;<a href="mailto:danny.gershman@gmail.com" target="_blank">danny.gershman@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Not sure this is helpful for you, but create a simple TCP socket connection with NodeJS.  When there is a connection failure an immediate callback occurs.</div><div><div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 5, 2015 at 6:25 AM Stanislav Sinyagin &lt;<a href="mailto:ssinyagin@gmail.com" target="_blank">ssinyagin@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">it&#39;s not Java-specific really.<br>
<br>
Imagine you have an open TCP connection that has no traffic, and<br>
somewhere inbetween there&#39;s a network failure. You will only know<br>
about it when you start sending the data, and the TCP timeout occurs.<br>
You will get the socket error exception only after all retransmission<br>
attempts failed, and that may take quite some significant time. If<br>
ICMP is allowed in the network, some failures would generate ICMP<br>
messages which will speed up the process, but you can&#39;t rely on this.<br>
<br>
So, if you need to know about the failure quickly enough, you need to<br>
monitor the server reachability with some connectionless protocol,<br>
like ICMP echo or some UDP-based keepalive.<br>
<br>
<br>
<br>
<br>
<br>
On Wed, Aug 5, 2015 at 11:14 AM, Michael Jerris &lt;<a href="mailto:mike@jerris.com" target="_blank">mike@jerris.com</a>&gt; wrote:<br>
&gt; are you saying Java provides no way to detect a tcp socket disconnect?<br>
&gt;<br>
&gt;<br>
&gt; On Wednesday, August 5, 2015, Babak Yakhchali &lt;<a href="mailto:babak.freeswitch@gmail.com" target="_blank">babak.freeswitch@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; but if for example network connection is lost the socket will remain open<br>
&gt;&gt; forever!<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Aug 5, 2015 at 12:04 PM, Michael Jerris &lt;<a href="mailto:mike@jerris.com" target="_blank">mike@jerris.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I would just detect the socket closing instead of using a heartbeat for<br>
&gt;&gt;&gt; sure<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Wednesday, August 5, 2015, Babak Yakhchali<br>
&gt;&gt;&gt; &lt;<a href="mailto:babak.freeswitch@gmail.com" target="_blank">babak.freeswitch@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hi<br>
&gt;&gt;&gt;&gt; I&#39;m using pure java sockets (not current available esl implementations)<br>
&gt;&gt;&gt;&gt; with event_socket to control sessions. to detect lan disconnects I&#39;m using<br>
&gt;&gt;&gt;&gt; session_heartbeat events every 1 second (this is adjustable). Considering<br>
&gt;&gt;&gt;&gt; performance is this a bad approach or not ? any better suggestions?<br>
&gt;&gt;&gt;&gt; if I execute enable_heartbeat before answering the call this message is<br>
&gt;&gt;&gt;&gt; printed on console:<br>
&gt;&gt;&gt;&gt; switch_core_session.c:1555 sofia/internal/<a href="mailto:1000@172.16.90.1" target="_blank">1000@172.16.90.1</a> using<br>
&gt;&gt;&gt;&gt; scheduler due to bypass media or media is not established.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; should I answer the session before calling enable_heartbeat?<br>
&gt;&gt;&gt;&gt; thanks<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; _________________________________________________________________________<br>
&gt;&gt;&gt; Professional FreeSWITCH Consulting Services:<br>
&gt;&gt;&gt; <a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
&gt;&gt;&gt; <a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.freeswitchsolutions.com</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Official FreeSWITCH Sites<br>
&gt;&gt;&gt; <a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
&gt;&gt;&gt; <a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.org</a><br>
&gt;&gt;&gt; <a href="http://www.cluecon.com" rel="noreferrer" target="_blank">http://www.cluecon.com</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; FreeSWITCH-users mailing list<br>
&gt;&gt;&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt;&gt;&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt;&gt;&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt;&gt;&gt; <a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt; _________________________________________________________________________<br>
&gt; Professional FreeSWITCH Consulting Services:<br>
&gt; <a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
&gt; <a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.freeswitchsolutions.com</a><br>
&gt;<br>
&gt; Official FreeSWITCH Sites<br>
&gt; <a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
&gt; <a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.org</a><br>
&gt; <a href="http://www.cluecon.com" rel="noreferrer" target="_blank">http://www.cluecon.com</a><br>
&gt;<br>
&gt; FreeSWITCH-users mailing list<br>
&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt; <a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<br>
_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div>
</div></div><br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br></div>
</div></div><br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.org</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br></div>