Details
Description
I use MINA 2.0.0 M1 and M2 to build my application.
When I use one NioSocketConnector to generate 10 sessions and then close them in the messageReceived event of each session, only 5 or 6 sessions(that is to say, not of all sessions) can be closed correctly, others cannot, but I can receive the sessionClosed event. The number of the closed sessions varies from 2-6 during my experiments.
Another intersting event will occur:
Since the rest sessions cannot be closed, I tried to generate a new session by the same NioSocketConnector, then all of the 10 "old" sessions were closed as one might expect, except the last new session.
the main method:
public static void main(String[] args)
{
NioSocketConnector acceptor = new NioSocketConnector();
acceptor.setDefaultRemoteAddress(new InetSocketAddress("127.0.0.1", 2361));
acceptor.getFilterChain().addLast( "executor", new ExecutorFilter(100) );
acceptor.setHandler( new TimeServerHandler() );
for(int i=0; i<10; i++)
acceptor.connect();
}
the messageReceived method in TimeServerHandler class:
public void messageReceived(IoSession session, Object message)
throws Exception
{
System.out.println(((IoBuffer) message).getString(Charset.forName("UTF-8")
.newDecoder()));
session.close();
}
the log of the test server:
2008-5-27 17:09:32 Connected ++++++++++++++++++++++++127.0.0.1 / 3211>
2008-5-27 17:09:32 Connected ++++++++++++++++++++++++127.0.0.1 / 3212>
2008-5-27 17:09:32 Connected ++++++++++++++++++++++++127.0.0.1 / 3213>
2008-5-27 17:09:32 Connected ++++++++++++++++++++++++127.0.0.1 / 3214>
2008-5-27 17:09:32 Connected ++++++++++++++++++++++++127.0.0.1 / 3215>
2008-5-27 17:09:32 Connected ++++++++++++++++++++++++127.0.0.1 / 3216>
2008-5-27 17:09:32 Connected ++++++++++++++++++++++++127.0.0.1 / 3217>
2008-5-27 17:09:32 Connected ++++++++++++++++++++++++127.0.0.1 / 3218>
2008-5-27 17:09:32 Connected ++++++++++++++++++++++++127.0.0.1 / 3219>
2008-5-27 17:09:32 Connected ++++++++++++++++++++++++127.0.0.1 / 3220>
2008-5-27 17:09:32 Disconnected -----------------------127.0.0.1 / 3211>
2008-5-27 17:09:32 Disconnected -----------------------127.0.0.1 / 3213>
2008-5-27 17:09:32 Disconnected -----------------------127.0.0.1 / 3214>
2008-5-27 17:09:32 Disconnected -----------------------127.0.0.1 / 3212>
2008-5-27 17:09:32 Disconnected -----------------------127.0.0.1 / 3216>
2008-5-27 17:09:32 Disconnected -----------------------127.0.0.1 / 3215>
2008-5-27 17:09:37 Connected ++++++++++++++++++++++++127.0.0.1 / 3221>
2008-5-27 17:09:37 Disconnected -----------------------127.0.0.1 / 3217>
2008-5-27 17:09:37 Disconnected -----------------------127.0.0.1 / 3218>
2008-5-27 17:09:37 Disconnected -----------------------127.0.0.1 / 3219>
2008-5-27 17:09:37 Disconnected -----------------------127.0.0.1 / 3220>