Hi Maarten...
here is my server 

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.charset.*;
import org.apache.mina.common.IoAcceptor;
import org.apache.mina.transport.socket.nio.SocketAcceptor;
import org.apache.mina.transport.socket.nio.*;
import org.apache.mina.common.*;
import org.apache.mina.filter.*;
import org.apache.mina.filter.codec.*;
import org.apache.mina.filter.codec.textline.*;

import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.mina.integration.jmx.IoServiceManager;

public class Main {
    private static final int PORT = 6082;
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        ByteBuffer.setUseDirectBuffers(false);
        ByteBuffer.setAllocator(new SimpleByteBufferAllocator());

        IoAcceptor acceptor = new SocketAcceptor();

        
        SocketAcceptorConfig  cfg = new SocketAcceptorConfig();
        cfg.getSessionConfig().setReuseAddress( true );
        cfg.getFilterChain().addLast( "logger", new LoggingFilter() );
        cfg.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new 
TextLineCodecFactory( Charset.forName( "UTF-8" ))));

        IoServiceManager serviceManager = new IoServiceManager( acceptor );
        serviceManager.startCollectingStats(1000);
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        
        try {
            ObjectName name = new 
ObjectName("com.jels.kaddb.gateway:type=IoServiceManager");
            mbs.registerMBean(serviceManager, name);

            acceptor.bind( new InetSocketAddress(PORT), new ConnHandler(), cfg);
        }
        catch (Exception e) {
            
        }
        
        System.out.println("Tracking Gateway server started.");        
    }
    
    public void sessionCreated(IoSession session) throws Exception {
        System.out.println("Session created...");

    }


}

I tired  US_ASCII, ISO-8859-1 and UTF-8 for charset and same problem appeared 
** I use mina-core-1.1.0.jar

Thanks in advance 

Maarten Bosteels <[EMAIL PROTECTED]> wrote: Hi Ahmed,

Could you show us how you set up the server ?
Which ExecutorFilter and ProtocolCodecFilter you use, etc..

Thanks,
Maarten

On 7/9/07, Ahmed Al-Obaidy  wrote:
>
> 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.


       
---------------------------------
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, 
photos & more. 
 
---------------------------------
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.

Reply via email to