Thanks for the help Mike, I should write a ProtocolCodec similar to TextLine but that includes a check for Binary content. Could I use the session parameter to tell the decoder that this message is binary?
I will give it a try, Thanks again, Aidan ---------------------------------------- From: Mike Heath <[EMAIL PROTECTED]> Sent: 23 August 2007 18:25 To: [email protected] Subject: Re: Decoding text and binary using MINA You could base64 encode your binary data if you don't want to write your own codec. This will increase the amount of data being sent over the wire but it's easy to do. Writing a codec that that passes the ByteBuffer straight through when you're in binary mode and uses the TextLineCodec when you're not should be fairly simple to create if you don't want to go down the base64 route. -Mike Aidan Gallagher wrote: > Hi everyone, > > > > I am building a client server application using MINA and have a small query. > > > > 99% of the communication between the client and the server is text. > Therefore I use the TextLineCodecFactory as the protocol codec. > > > > However I also need to send binary image data from the client to the server > on occasion and that causes an exception. > > > > Aug 23, 2007 4:14:55 PM org.apache.mina.util.SessionLog error > > SEVERE: [/89.192.26.238:1102] Exception: > > org.apache.mina.filter.codec.ProtocolDecoderException: > java.nio.charset.MalformedInputException: Input length = 1 (Hexdump: empty) > > at > org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCod > ecFilter.java:163) > > at > org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived > (AbstractIoFilterChain.java:299) > > at > org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoF > ilterChain.java:53) > > at > org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageRece > ived(AbstractIoFilterChain.java:648) > > at > org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilter.j > ava:220) > > at > org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run(Exe > cutorFilter.java:264) > > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.ja > va:885) > > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:9 > 07) > > at java.lang.Thread.run(Thread.java:619) > > Caused by: java.nio.charset.MalformedInputException: Input length = 1 > > at java.nio.charset.CoderResult.throwException(CoderResult.java:260) > > at org.apache.mina.common.ByteBuffer.getString(ByteBuffer.java:952) > > at > org.apache.mina.filter.codec.textline.TextLineDecoder.decodeAuto(TextLineDec > oder.java:178) > > at > org.apache.mina.filter.codec.textline.TextLineDecoder.decode(TextLineDecoder > .java:112) > > at > org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCod > ecFilter.java:156) > > ... 8 more > > > > Will I have to write my own protocol codec for this case? > > > > Thanks for all your help MINA is a great product > > > > Aidan > >
