Hi guys,

I'm using MINA to develop a GPRS gateway for an AVL system...

Now I'm using a very simple program for evaluation purpose ...
It just print messages come from TCP clients to the System.out

Tests works OK under Linux/telnet...

When I use it under Windows/Telnet I find a strange behavior  showed up...
The telnet window doesn't echo my input... and the program output log each 
character separately... but the  IoHandlerAdapter still capture the messages 
events....
the output seems like this:

Tracking Gateway server started.
20578 [SocketAcceptorIoProcessor-0.0] INFO ConnHandler - [/127.0.0.1:1237] 
CREATED
20578 [AnonymousIoService-1] INFO ConnHandler - [/127.0.0.1:1237] OPENED
23922 [AnonymousIoService-2] INFO ConnHandler - [/127.0.0.1:1237] RECEIVED: 
HeapBuffer[pos=0 lim=1 cap=8192: 68]
24172 [AnonymousIoService-3] INFO ConnHandler - [/127.0.0.1:1237] RECEIVED: 
HeapBuffer[pos=0 lim=1 cap=8192: 69]
27781 [AnonymousIoService-4] INFO ConnHandler - [/127.0.0.1:1237] RECEIVED: 
HeapBuffer[pos=0 lim=2 cap=8192: 0D 0A]
Message
ST:hi


Even more, when tracking devices connect the server... the messages appear in 
the Log.. but the IoHandlerAdapter never catch the messages events...
the output look like this

Tracking Gateway server started.
57453 [SocketAcceptorIoProcessor-0.0] INFO ConnHandler - [/213.139.63.254:3599] 
CREATED
57469 [AnonymousIoService-1] INFO ConnHandler - [/213.139.63.254:3599] OPENED
58859 [AnonymousIoService-2] INFO ConnHandler - [/213.139.63.254:3599] 
RECEIVED: HeapBuffer[pos=0 lim=102 cap=8192: 33 35 33 35 37 39 30 31 34 38 34 
32 33 36 39 2C 30 35 2A 38 32 37 2C 30 30 30 2C 50 54 33 33 2C 56 2C 30 30 30 
30 2E 30 30 30 30 2C 4E 2C 30 30 30 30 30 2E 30 30 30 30 2C 45 2C 30 30 30 2E 
30 2C 30 30 30 2E 30 2C 30 30 2E 30 2C 30 30 3A 30 30 3A 31 37 20 30 36 2D 30 
31 2D 38 30 2C 32 2E 32 31 2C 39 39 0D]
78672 [AnonymousIoService-3] INFO ConnHandler - [/213.139.63.254:3599] 
RECEIVED: HeapBuffer[pos=0 lim=102 cap=8192: 33 35 33 35 37 39 30 31 34 38 34 
32 33 36 39 2C 30 35 2A 38 32 37 2C 30 30 30 2C 50 54 33 33 2C 56 2C 30 30 30 
30 2E 30 30 30 30 2C 4E 2C 30 30 30 30 30 2E 30 30 30 30 2C 45 2C 30 30 30 2E 
30 2C 30 30 30 2E 30 2C 30 30 2E 30 2C 30 30 3A 30 30 3A 34 39 20 30 36 2D 30 
31 2D 38 30 2C 32 2E 32 31 2C 39 39 0D]
98672 [AnonymousIoService-4] INFO ConnHandler - [/213.139.63.254:3599] 
RECEIVED: HeapBuffer[pos=0 lim=102 cap=8192: 33 35 33 35 37 39 30 31 34 38 34 
32 33 36 39 2C 30 35 2A 38 32 37 2C 30 30 30 2C 50 54 33 33 2C 56 2C 30 30 30 
30 2E 30 30 30 30 2C 4E 2C 30 30 30 30 30 2E 30 30 30 30 2C 45 2C 30 30 30 2E 
30 2C 30 30 30 2E 30 2C 30 30 2E 30 2C 30 30 3A 30 31 3A 30 39 20 30 36 2D 30 
31 2D 38 30 2C 32 2E 32 31 2C 39 39 0D]

here is my IoHandlerAdapter  

 import java.util.*;
import org.apache.mina.common.IoHandlerAdapter;
import org.apache.mina.common.IoSession;
import org.apache.mina.common.*;
import org.apache.mina.transport.socket.nio.*;

public class ConnHandler extends IoHandlerAdapter {
    //private Map sessions=Collections.synchronizedMap(new HashMap());

    public void exceptionCaught(IoSession session, Throwable t) throws 
Exception {
        t.printStackTrace();
        session.close();
    }

    public void messageReceived(IoSession session, Object msg) throws Exception 
{
        System.out.println("Message");
        String str = msg.toString();

        //foreach (IoSession s in sessions.)
        
        //session.write( "You said:" + str );
        System.out.println("ST:"+str);
    }
}

I think the problem has something to do with the charset... I tried many but no 
success...


       
---------------------------------
Looking for a deal? Find great prices on flights and hotels with Yahoo! 
FareChase.

Reply via email to