I'm working on this problem right now (for long polling connections) . What I'm doing is creating a message_cache object for each session. the problem comes when you try to send two or more messages back to back. I COULD block the push untill I get an atach event, but that never seems to happen? Is this just me? does everyone else get the atach event in comet handler?
Anyway what I'm thinking is setting up a block timer between pushes set to 250 1/4 of a second, to allow the system time to settle down. Any Ideas?
--Richard
----- Original Message ----
From: Oleksiy Stashok <Oleksiy.Stashok@Sun.COM>
To: users@grizzly.dev.java.net
Sent: Wed, December 23, 2009 4:41:16 AM
Subject: Re: detect network disconnected?
Hi,
> IIRC, if a read attempt is done on channel that has its network cable unplugged should result in some kind of an IOException being thrown even if there is no data readily available on the channel.
>
> So, some kind of "heart beat" mechanism that does a periodic read() of a channel should detect a disconnected network cable.
>
> Perhaps a simple program would prove / disprove this?
Agree. From what I know, if connection was closed read() operation will return either -1 or throw IOException (depending on OS and JDK).
Unfortunately it's also true, that write operation may succeed on connection, which was closed by peer.
Also agree, that "Heart beat" mechanism could be a good solution.
WBR,
Alexey.
>
> charlie ...
>
> ichinco wrote:
>> Not quite. We have implemented this, but it does not close the channel if the
>> network cable is unplugged. (neither remotlyclosed nor locallyclosed
>> functions get called.)
>>
>> I'm most surprised that you can still write (without an exception!) to a
>> channel whose client is no longer connected to the network.
>>
>>
>> survivant wrote:
>>
>>> can this blog help you ?
>>>
>>>
http://weblogs.java.net/blog/2008/11/25/grizzly-how-be-notify-when-client-disconnect
>>>
>>>
>>>
>>> 2009/12/22 ichinco <ichinco@gmail.com>
>>>
>>>
>>>> Hello, all,
>>>>
>>>> Is there a way to tell on the server-side whether a client has lost
>>>> network
>>>> connection (ie, network cable pulled)?
>>>>
>>>> The channel doesn't get closed automatically,
>>>> SelectionKey.channel().isOpen() reports true, and if I try to write to it
>>>> (OutputWriter.flushChannel), there is no IOError. Is there a fool-proof
>>>> way
>>>> to tell whether the channel is still open from the server side?
>>>>
>>>> Thanks!
>>>> --
>>>> View this message in context:
>>>>
http://old.nabble.com/detect-network-disconnected--tp26891745p26891745.html
>>>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@grizzly.dev.java.net
>>>> For additional commands, e-mail: users-help@grizzly.dev.java.net
>>>>
>>>>
>>>>
>>> ---------------
>>> A+
>>>
>>> Sébastien.
>>>
>>> Vous pouvez me suivre sur Twitter / You can follow me on Twitter :
>>>
http://twitter.com/survivant
>>>
>>>
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@grizzly.dev.java.net
> For additional commands, e-mail: users-help@grizzly.dev.java.net
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@grizzly.dev.java.net
For additional commands, e-mail: users-help@grizzly.dev.java.net