Hello ~
I'm trying to build a simple server that utilizes the KeepAlive
functionality in Mina, but am having trouble getting it working. After
reading the javadoc I am able to create a KeepAliveFilter in my filter chain
that works with client-side keep alive requests:
acceptor.getFilterChain().addLast("logger", new LoggingFilter());
acceptor.getFilterChain().addLast("keepAlive", new KeepAliveFilter(new
MyKeepAliveMessageFactory(), KeepAliveRequestTimeoutHandler.LOG));
acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new
TextLineCodecFactory(Charset.forName("UTF-8"))));
However when I wish to pass back a keep-alive response to my client this
exception gets thrown:
java.lang.IllegalStateException: Don't know how to handle message of type
'java.lang.String'. Are you missing a protocol encoder?
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.flushNow(AbstractPollingIoProcessor.java:789)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.flush(AbstractPollingIoProcessor.java:692)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$8(AbstractPollingIoProcessor.java:677)
...
It's obvious to me that I cannot pass back a string from getResponse() but
I'm unsure of how to add the appropriate protocol encoder. After googling
and scanning the MLs I was unable to find any examples that implement
KeepAliveMessageFactory. Any suggestions?
Thanks!
ken