users@grizzly.java.net

Canceling connection expiration?

From: Igor Minar <iiminar_at_gmail.com>
Date: Sun, 3 Aug 2008 21:30:34 -0700

Heya,

It looks like I have actually quite a few questions about Grizzly. :-)

I stumbled upon a similar issue that was discussed here: http://www.nabble.com/1.7.3.3-drop-connection-every-30-seconds-td17674241.html

The difference is that I'm extending Grizzly via an async filter that
I'd like to use with Glassfish. My filter streams a lot of data to the
client and when it's done streaming it will close the connection.

The problem I have is that if the data transfer to the client takes
longer than 30 seconds, the SocketChannel gets closed by the
SelectorThread and I receive:

java.nio.channels.AsynchronousCloseException
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:
312)
        at MyTask.doTask(SendfileTask.java:78)
        at
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
        at
com
.sun
.enterprise
.web.connector.grizzly.WorkerThreadImpl.run(WorkerThreadImpl.java:116)


or

java.nio.channels.ClosedChannelException
        at
sun.nio.ch.SocketChannelImpl.ensureWriteOpen(SocketChannelImpl.java:125)
        at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:
294)
        at MyTask.doTask(SendfileTask.java:79)
        at
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
        at
com
.sun
.enterprise
.web.connector.grizzly.WorkerThreadImpl.run(WorkerThreadImpl.java:116)


How can I prevent the channel from being closed? I don't want to
modify the timeout that would affect all the connections (only some
requests are being processed by the filter). I'm not quite sure if it
would be better to cancel the expiration for these connections
altogether, or just set the value to something really high. At this
point, whatever gets me going will be fine for now.


cheers,
Igor