<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;" class="">I strongly agree with that. java-esl helps a lot.<div class=""><br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 5, 2015, at 9:25 AM, Hector Geraldino <<a href="mailto:Hector.Geraldino@ipsoft.com" class="">Hector.Geraldino@ipsoft.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: Calibri, sans-serif;" class="">
<div class="">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 class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class=""><br class="">
</div>
<span id="OLK_SRC_BODY_SECTION" class="">
<div style="font-family: Calibri; font-size: 11pt; text-align: left; border-width: 1pt medium medium; border-style: solid none none; padding: 3pt 0in 0in; border-top-color: rgb(181, 196, 223);" class="">
<span style="font-weight:bold" class="">From: </span><<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" class="">freeswitch-users-bounces@lists.freeswitch.org</a>> on behalf of Babak Yakhchali <<a href="mailto:babak.freeswitch@gmail.com" class="">babak.freeswitch@gmail.com</a>><br class="">
<span style="font-weight:bold" class="">Reply-To: </span>FreeSWITCH Users Help <<a href="mailto:freeswitch-users@lists.freeswitch.org" class="">freeswitch-users@lists.freeswitch.org</a>><br class="">
<span style="font-weight:bold" class="">Date: </span>Wednesday, August 5, 2015 at 6:54 AM<br class="">
<span style="font-weight:bold" class="">To: </span>FreeSWITCH Users Help <<a href="mailto:freeswitch-users@lists.freeswitch.org" class="">freeswitch-users@lists.freeswitch.org</a>><br class="">
<span style="font-weight:bold" class="">Subject: </span>Re: [Freeswitch-users] using enable_heartbeat to detect network problems in event_socket<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div dir="ltr" class="">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 class="">
<div class="gmail_quote">On Wed, Aug 5, 2015 at 3:21 PM, Regis M <span dir="ltr" class="">
<<a href="mailto:regis.freeswitch.org@tornad.net" target="_blank" class="">regis.freeswitch.org@tornad.net</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" type="cite">
<div dir="ltr" class="">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 class="">
<div class="gmail_quote">2015-08-05 12:35 GMT+02:00 Danny Gershman <span dir="ltr" class="">
<<a href="mailto:danny.gershman@gmail.com" target="_blank" class="">danny.gershman@gmail.com</a>></span>:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" type="cite">
<div dir="ltr" class="">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 class="">
<div class=""><br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Wed, Aug 5, 2015 at 6:25 AM Stanislav Sinyagin <<a href="mailto:ssinyagin@gmail.com" target="_blank" class="">ssinyagin@gmail.com</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" type="cite">
it's not Java-specific really.<br class="">
<br class="">
Imagine you have an open TCP connection that has no traffic, and<br class="">
somewhere inbetween there's a network failure. You will only know<br class="">
about it when you start sending the data, and the TCP timeout occurs.<br class="">
You will get the socket error exception only after all retransmission<br class="">
attempts failed, and that may take quite some significant time. If<br class="">
ICMP is allowed in the network, some failures would generate ICMP<br class="">
messages which will speed up the process, but you can't rely on this.<br class="">
<br class="">
So, if you need to know about the failure quickly enough, you need to<br class="">
monitor the server reachability with some connectionless protocol,<br class="">
like ICMP echo or some UDP-based keepalive.<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
On Wed, Aug 5, 2015 at 11:14 AM, Michael Jerris <<a href="mailto:mike@jerris.com" target="_blank" class="">mike@jerris.com</a>> wrote:<br class="">
> are you saying Java provides no way to detect a tcp socket disconnect?<br class="">
><br class="">
><br class="">
> On Wednesday, August 5, 2015, Babak Yakhchali <<a href="mailto:babak.freeswitch@gmail.com" target="_blank" class="">babak.freeswitch@gmail.com</a>><br class="">
> wrote:<br class="">
>><br class="">
>> but if for example network connection is lost the socket will remain open<br class="">
>> forever!<br class="">
>><br class="">
>> On Wed, Aug 5, 2015 at 12:04 PM, Michael Jerris <<a href="mailto:mike@jerris.com" target="_blank" class="">mike@jerris.com</a>> wrote:<br class="">
>>><br class="">
>>> I would just detect the socket closing instead of using a heartbeat for<br class="">
>>> sure<br class="">
>>><br class="">
>>><br class="">
>>> On Wednesday, August 5, 2015, Babak Yakhchali<br class="">
>>> <<a href="mailto:babak.freeswitch@gmail.com" target="_blank" class="">babak.freeswitch@gmail.com</a>> wrote:<br class="">
>>>><br class="">
>>>> Hi<br class="">
>>>> I'm using pure java sockets (not current available esl implementations)<br class="">
>>>> with event_socket to control sessions. to detect lan disconnects I'm using<br class="">
>>>> session_heartbeat events every 1 second (this is adjustable). Considering<br class="">
>>>> performance is this a bad approach or not ? any better suggestions?<br class="">
>>>> if I execute enable_heartbeat before answering the call this message is<br class="">
>>>> printed on console:<br class="">
>>>> switch_core_session.c:1555 sofia/internal/<a href="mailto:1000@172.16.90.1" target="_blank" class="">1000@172.16.90.1</a> using<br class="">
>>>> scheduler due to bypass media or media is not established.<br class="">
>>>><br class="">
>>>> should I answer the session before calling enable_heartbeat?<br class="">
>>>> thanks<br class="">
>>><br class="">
>>><br class="">
>>> _________________________________________________________________________<br class="">
>>> Professional FreeSWITCH Consulting Services:<br class="">
>>> <a href="mailto:consulting@freeswitch.org" target="_blank" class="">consulting@freeswitch.org</a><br class="">
>>> <a href="http://www.freeswitchsolutions.com/" rel="noreferrer" target="_blank" class="">
http://www.freeswitchsolutions.com</a><br class="">
>>><br class="">
>>> Official FreeSWITCH Sites<br class="">
>>> <a href="http://www.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://www.freeswitch.org</a><br class="">
>>> <a href="http://confluence.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://confluence.freeswitch.org</a><br class="">
>>> <a href="http://www.cluecon.com/" rel="noreferrer" target="_blank" class="">http://www.cluecon.com</a><br class="">
>>><br class="">
>>> FreeSWITCH-users mailing list<br class="">
>>> <a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank" class="">FreeSWITCH-users@lists.freeswitch.org</a><br class="">
>>> <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank" class="">
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br class="">
>>> UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank" class="">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br class="">
>>> <a href="http://www.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://www.freeswitch.org</a><br class="">
>><br class="">
>><br class="">
><br class="">
> _________________________________________________________________________<br class="">
> Professional FreeSWITCH Consulting Services:<br class="">
> <a href="mailto:consulting@freeswitch.org" target="_blank" class="">consulting@freeswitch.org</a><br class="">
> <a href="http://www.freeswitchsolutions.com/" rel="noreferrer" target="_blank" class="">http://www.freeswitchsolutions.com</a><br class="">
><br class="">
> Official FreeSWITCH Sites<br class="">
> <a href="http://www.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://www.freeswitch.org</a><br class="">
> <a href="http://confluence.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://confluence.freeswitch.org</a><br class="">
> <a href="http://www.cluecon.com/" rel="noreferrer" target="_blank" class="">http://www.cluecon.com</a><br class="">
><br class="">
> FreeSWITCH-users mailing list<br class="">
> <a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank" class="">FreeSWITCH-users@lists.freeswitch.org</a><br class="">
> <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank" class="">
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br class="">
> UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank" class="">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br class="">
> <a href="http://www.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://www.freeswitch.org</a><br class="">
<br class="">
_________________________________________________________________________<br class="">
Professional FreeSWITCH Consulting Services:<br class="">
<a href="mailto:consulting@freeswitch.org" target="_blank" class="">consulting@freeswitch.org</a><br class="">
<a href="http://www.freeswitchsolutions.com/" rel="noreferrer" target="_blank" class="">http://www.freeswitchsolutions.com</a><br class="">
<br class="">
Official FreeSWITCH Sites<br class="">
<a href="http://www.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://www.freeswitch.org</a><br class="">
<a href="http://confluence.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://confluence.freeswitch.org</a><br class="">
<a href="http://www.cluecon.com/" rel="noreferrer" target="_blank" class="">http://www.cluecon.com</a><br class="">
<br class="">
FreeSWITCH-users mailing list<br class="">
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank" class="">FreeSWITCH-users@lists.freeswitch.org</a><br class="">
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank" class="">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br class="">
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank" class="">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br class="">
<a href="http://www.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://www.freeswitch.org</a><br class="">
</blockquote>
</div>
</div>
</div>
<br class="">
_________________________________________________________________________<br class="">
Professional FreeSWITCH Consulting Services:<br class="">
<a href="mailto:consulting@freeswitch.org" target="_blank" class="">consulting@freeswitch.org</a><br class="">
<a href="http://www.freeswitchsolutions.com/" rel="noreferrer" target="_blank" class="">http://www.freeswitchsolutions.com</a><br class="">
<br class="">
Official FreeSWITCH Sites<br class="">
<a href="http://www.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://www.freeswitch.org</a><br class="">
<a href="http://confluence.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://confluence.freeswitch.org</a><br class="">
<a href="http://www.cluecon.com/" rel="noreferrer" target="_blank" class="">http://www.cluecon.com</a><br class="">
<br class="">
FreeSWITCH-users mailing list<br class="">
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank" class="">FreeSWITCH-users@lists.freeswitch.org</a><br class="">
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank" class="">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br class="">
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank" class="">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br class="">
<a href="http://www.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://www.freeswitch.org</a><br class="">
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
<br class="">
_________________________________________________________________________<br class="">
Professional FreeSWITCH Consulting Services:<br class="">
<a href="mailto:consulting@freeswitch.org" class="">consulting@freeswitch.org</a><br class="">
<a href="http://www.freeswitchsolutions.com/" rel="noreferrer" target="_blank" class="">http://www.freeswitchsolutions.com</a><br class="">
<br class="">
Official FreeSWITCH Sites<br class="">
<a href="http://www.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://www.freeswitch.org</a><br class="">
<a href="http://confluence.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://confluence.freeswitch.org</a><br class="">
<a href="http://www.cluecon.com/" rel="noreferrer" target="_blank" class="">http://www.cluecon.com</a><br class="">
<br class="">
FreeSWITCH-users mailing list<br class="">
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" class="">FreeSWITCH-users@lists.freeswitch.org</a><br class="">
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank" class="">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br class="">
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank" class="">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br class="">
<a href="http://www.freeswitch.org/" rel="noreferrer" target="_blank" class="">http://www.freeswitch.org</a><br class="">
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</span>
</div>
_________________________________________________________________________<br class="">Professional FreeSWITCH Consulting Services: <br class=""><a href="mailto:consulting@freeswitch.org" class="">consulting@freeswitch.org</a><br class="">http://www.freeswitchsolutions.com<br class=""><br class="">Official FreeSWITCH Sites<br class="">http://www.freeswitch.org<br class="">http://confluence.freeswitch.org<br class="">http://www.cluecon.com<br class=""><br class="">FreeSWITCH-users mailing list<br class="">FreeSWITCH-users@lists.freeswitch.org<br class="">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<br class="">UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<br class="">http://www.freeswitch.org</div></blockquote></div><br class=""></div></div></body></html>