<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><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 5, 2015 at 6:25 AM Stanislav Sinyagin <<a href="mailto:ssinyagin@gmail.com">ssinyagin@gmail.com</a>> 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 <<a href="mailto:mike@jerris.com" target="_blank">mike@jerris.com</a>> wrote:<br>
> are you saying Java provides no way to detect a tcp socket disconnect?<br>
><br>
><br>
> On Wednesday, August 5, 2015, Babak Yakhchali <<a href="mailto:babak.freeswitch@gmail.com" target="_blank">babak.freeswitch@gmail.com</a>><br>
> wrote:<br>
>><br>
>> but if for example network connection is lost the socket will remain open<br>
>> forever!<br>
>><br>
>> On Wed, Aug 5, 2015 at 12:04 PM, Michael Jerris <<a href="mailto:mike@jerris.com" target="_blank">mike@jerris.com</a>> wrote:<br>
>>><br>
>>> I would just detect the socket closing instead of using a heartbeat for<br>
>>> sure<br>
>>><br>
>>><br>
>>> On Wednesday, August 5, 2015, Babak Yakhchali<br>
>>> <<a href="mailto:babak.freeswitch@gmail.com" target="_blank">babak.freeswitch@gmail.com</a>> wrote:<br>
>>>><br>
>>>> Hi<br>
>>>> I'm using pure java sockets (not current available esl implementations)<br>
>>>> with event_socket to control sessions. to detect lan disconnects I'm using<br>
>>>> session_heartbeat events every 1 second (this is adjustable). Considering<br>
>>>> performance is this a bad approach or not ? any better suggestions?<br>
>>>> if I execute enable_heartbeat before answering the call this message is<br>
>>>> printed on console:<br>
>>>> 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>
>>>> scheduler due to bypass media or media is not established.<br>
>>>><br>
>>>> should I answer the session before calling enable_heartbeat?<br>
>>>> thanks<br>
>>><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>
>><br>
>><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>
<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>