I'm facing similar issue; When I use IoHandlerAdapter and print messages
from client, 
 
  ByteBuffer rb = ( ByteBuffer ) message;
       
        System.out.println("data received:" );
        
        while( rb.hasRemaining() )
        {
            System.out.print( ( char ) rb.get() );
        }
        System.out.flush();

it works fine. I tried the same logic with StreamIoHandler like this:
 
            BufferedReader in = new BufferedReader(
                    new InputStreamReader( this.in ) );
                
                String line;
                while ( ( line = in.readLine() ) != null &&
!line.equals( "" ) )
                {
                        System.out.println("data is:" + line);
                }

After the data is printed, there is an exception
 
java.io.IOException: Stream is closed.
 at
org.apache.mina.handler.support.IoSessionInputStream.waitForData(IoSessionInputStream.java:131)
 at
org.apache.mina.handler.support.IoSessionInputStream.read(IoSessionInputStream.java:102)
 at
sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)
 at
sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)
 at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)
 at java.io.InputStreamReader.read(InputStreamReader.java:167)
 at java.io.BufferedReader.fill(BufferedReader.java:136)
 at java.io.BufferedReader.readLine(BufferedReader.java:299)
 at java.io.BufferedReader.readLine(BufferedReader.java:362)

 
I can't change the client to send new line or keep the connection open.
Any suggestions how to solve this?
 
thanks
Babu
 
>>> <[EMAIL PROTECTED]> Thursday, July 13, 2006 4:53:38 PM
>>>


Hi, 

Which decoder are you using? 

You can define your own protocol encoders and decoders which can handle
the data in whatever way you choose - you simply get a ByteBuffer which
you can decode. 

Robert 


[EMAIL PROTECTED] 
13/07/2006 22:42 
Please respond to mina-dev         
        To:        [email protected] 
        cc:         
        Subject:        Re: messageReceived() & dataRead() not called
when Commons.TelnetClient sends messages


I have resolved the problem: the TelnetClient did not append a new line
to 
the end of each write. I didn't realise that MINA IoHandler required a

newline in order to receive a line of data. I am curious as to how
other 
MINA users have resolved this when their incoming data did not include

newlines ('\n'), and they didn't have control over the client. Thanks
for 
your help.
  Best Regards,
               Elizabeth Clause 


This communication is for informational purposes only. It is not
intended
as an offer or solicitation for the purchase or sale of any financial
instrument or as an official confirmation of any transaction. All
market prices,
data and other information are not warranted as to completeness or
accuracy and
are subject to change without notice. Any comments or statements made
herein 
do not necessarily reflect those of JPMorgan Chase & Co., its
subsidiaries 
and affiliates. 

Reply via email to