Hi,
I've written a client/server application using MINA - the server is supposed
to tail log files and send the lines to any connected client. I've created
some protocol encoder/decoder and tried to do it similar to the example
here:
http://mina.apache.org/mina-project/userguide/ch9-codec-filter/ch9-codec-filter.html
The server queues up a number of log lines, and sends them as a message with
length-integer first, and all the bytes following. This seems to work well.
However, when I try to combine this with a KeepAliveFilter, to keep the
connection alive, it (the server) seems to crash occasionally. I'm not sure
why, if it's "colliding" with the keepalive somehow, or what happens.
The error I'm getting is this:
java.nio.InvalidMarkException
at java.nio.Buffer.reset(Buffer.java:297)
at
org.apache.mina.core.buffer.AbstractIoBuffer.reset(AbstractIoBuffer.java:414)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.writeBuffer(AbstractPollingIoProcessor.java:945)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.flushNow(AbstractPollingIoProcessor.java:861)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.flush(AbstractPollingIoProcessor.java:789)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$700(AbstractPollingIoProcessor.java:67)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1129)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:701)
Right now I'm adding the KeepAlive filter first, and the ProtocolCodecFilter
after that. I've tried to code the KeepAliveFilter similar to this:
http://opensourcejavaphp.net/java/mina/org/apache/mina/filter/keepalive/KeepAliveFilterTest.java.html
The client implements the getRequest() and the server implements the
getResponse() methods.
The keepalive seems to work when both client and server are idle (that is,
nothing is written to the server-monitored log files), but as soon as I put
some load on it (fill lots of text into the monitored log files), I get the
exception above in the server, sooner or later.
And again, if I remove the keepalive filter, it does not seem to crash like
this, no matter how hard I load it.
But I want keepalive :-( I've tried this with both MINA 2.0.5 and 2.0.7,
with the same result.
When writing from the server, I use:
//...
if
(!session.write(response).awaitUninterruptibly(10000)) {
logger.error("Failed to send data within 10
seconds (data size: " +
messageSize + ")");
//...
Any help is greatly appreciated!
--
View this message in context:
http://apache-mina.10907.n7.nabble.com/KeepAliveFilter-ProtocolCodecFilter-collides-tp41635.html
Sent from the Apache MINA User Forum mailing list archive at Nabble.com.