I've attached two test cases, one that works with MINA 1.1 (and works fine)
and other with MINA 2.0 that doesn't close connections.

This is a simple echo server that receives a message, writes it back to the
client and (should) close the connection.

On Jan 15, 2008 4:18 PM, Matteo Merli <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I'm having some problems in closing connections in a Mina 2.0 server
> (today updated svn, but the issue was already present)
>
> Basically, I'm notiicing that when I do a  connection.close() a FIN
> packet is not being sent to the client. Mina will consider the session
> as closed, but the client will not notice it.
>
> Trying to dig the problem (suspecting it was in my code) I took the
> "Echo server" example and changed it to close connection after the 1st
> response is sent:
>
> session.write(((IoBuffer) message).duplicate()).addListener(
> IoFutureListener.CLOSE );
>
> This is showing the same problem: no FIN packet is sent by the server.
> I've attached a tcpdump capture of the echo example.
>
> Is there some detail that I'm missing?
>
> Thank you,
> Matteo
>
> --
> Matteo Merli
> <[EMAIL PROTECTED]>
>



-- 
Matteo Merli
<[EMAIL PROTECTED]>
package mm.test;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;

import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoAcceptor;
import org.apache.mina.common.IoFutureListener;
import org.apache.mina.common.IoHandler;
import org.apache.mina.common.IoHandlerAdapter;
import org.apache.mina.common.IoSession;
import org.apache.mina.transport.socket.nio.SocketAcceptor;


public class Echo1_1
{
    static class Handler extends IoHandlerAdapter
    {
        @Override
        public void messageReceived( IoSession session, Object message ) throws 
Exception
        {
            ByteBuffer buf = (ByteBuffer) message;
            session.write( buf.duplicate() ).addListener( 
IoFutureListener.CLOSE );
        }
    }

    public static void main( String[] args ) throws IOException
    {
        IoAcceptor acceptor = new SocketAcceptor();

        IoHandler handler = new Handler();
        SocketAddress address = new InetSocketAddress( 9090 );

        acceptor.bind( address, handler );
    }
}
package mm.test;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;

import org.apache.mina.common.IoAcceptor;
import org.apache.mina.common.IoBuffer;
import org.apache.mina.common.IoFutureListener;
import org.apache.mina.common.IoHandler;
import org.apache.mina.common.IoHandlerAdapter;
import org.apache.mina.common.IoSession;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

public class Echo2_0
{
    static class Handler extends IoHandlerAdapter
    {
        @Override
        public void messageReceived( IoSession session, Object message ) throws 
Exception
        {
            IoBuffer buf = (IoBuffer) message;
            session.write( buf.duplicate() ).addListener( 
IoFutureListener.CLOSE );
        }
    }

    public static void main( String[] args ) throws IOException
    {
        IoAcceptor acceptor = new NioSocketAcceptor();

        IoHandler handler = new Handler();
        SocketAddress address = new InetSocketAddress( 9090 );

        acceptor.setHandler( handler );
        acceptor.bind( address );
    }
}

Reply via email to