<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>Well, let me suggest you to reconsider your approach. There’s a java library that uses ‘pure java sockets’ (java-esl), it’s based on netty (an implementation of the Java New IO (java.nio) API), and works like a charm. You can use this client library to
 register for events (heartbeat is one of them) and have a background thread to monitor for those events, while at the same time you can execute commands (answer calls, originate calls, bridge, hangup, schedule operations, etc) by just calling java methods
 on instances of the Client class.</div>
<div><br>
</div>
<div>I think it’s better to use the FreeSWITCH heartbeat event to detect network outages instead of relying on the session_heartbeat (heartbeat events per call). After all, a network outage will affect your control of all calls, so as soon as FS is unreachable,
 you won’t be able to control the calls anymore. For call disconnects, just listen for the CHANNEL_HANGUP event.</div>
<div><br>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>&lt;<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org">freeswitch-users-bounces@lists.freeswitch.org</a>&gt; on behalf of Babak Yakhchali &lt;<a href="mailto:babak.freeswitch@gmail.com">babak.freeswitch@gmail.com</a>&gt;<br>
<span style="font-weight:bold">Reply-To: </span>FreeSWITCH Users Help &lt;<a href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a>&gt;<br>
<span style="font-weight:bold">Date: </span>Wednesday, August 5, 2015 at 6:54 AM<br>
<span style="font-weight:bold">To: </span>FreeSWITCH Users Help &lt;<a href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a>&gt;<br>
<span style="font-weight:bold">Subject: </span>Re: [Freeswitch-users] using enable_heartbeat to detect network problems in event_socket<br>
</div>
<div><br>
</div>
<div>
<div>
<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&#43;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.&nbsp; 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's not Java-specific really.<br>
<br>
Imagine you have an open TCP connection that has no traffic, and<br>
somewhere inbetween there'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'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'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'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>
</div>
</div>
</span>
</body>
</html>