Salut,
Etienne Carouy wrote:
> Finally I found the option in Object DefaultSelectionKeyHandler.
>
>
>
> DefaultSelectionKeyHandler selection = *new* DefaultSelectionKeyHandler();
>
> selection.setTimeout(XXXX);
>
> tcpSelector.setSelectionKeyHandler(selection);
>
>
>
> This allows setting expiration time to a bigger value. It seems to work.
>
>
>
> Any better idea?
Yes, you can also completely disable the mechanism by doing:
> controller.setSelectionKeyHandler(new DefaultSelectionKeyHandler(){
>
> @Override
> public void expire(Iterator<SelectionKey> iterator) {
> // Do not expire connection
> }
> });
This way the connection will never be expired.
Thanks
-- Jeanfrancois
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> *De :* Etienne Carouy [mailto:etienne.carouy_at_market-ip.com]
> *Envoyé :* jeudi 26 juin 2008 14:41
> *À :* users_at_grizzly.dev.java.net
> *Objet :* Persistent tcp connection
>
>
>
> Hi all,
>
>
>
> I’ve working on an application that needs to manage a lot of socket in
> Java and was interested in Grizzly.
>
> The application is a GPRS server that received message from mobile
> device. The connection is persistent because the device sent about 1
> message / 5 minutes and that connection on GPRS network isn’t free.
>
> Currently, the application use normal socket and each device connected
> consume one thread (more than 1000 threads).
>
>
>
> I made some tests with grizzly but I got _java.net.SocketException_:
> Connection reset by peer: socket write error.
>
> This happens when the device sent a first message and wait 5 minutes to
> send the second one. I suppose that the server close the connection
> because of no sufficient activity.
>
>
>
> Is it possible to force the connection to stay open on the server side?
>
>
>
> Thanks in advance for your answer.
>
>
>
> Etienne Carouy
>