mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@apache.org>
Subject Re: closing a session in Mina 2.0.0-M6
Date Sat, 06 Jun 2009 15:10:42 GMT
Kelly Wiles wrote:
> Java version 1.6.0_13-b03
> Windows XP Pro 2002 SP 3
> Would be easiest if I could send a zip file.
> The zip file will contain source code, thread dump, client jar file 
> and server jar file and misc jars to run code.
> Unzip into a new  folder.
> To run the server prototiger_srv-1.0.0.jar on one computer
>   java -Djava.library.path=. -jar prototiger_srv-1.0.0.jar 2000
> And on another computer execute
>  java -Djava.library.path=. -jar prototiger_clt-1.0.0.jar <ip address 
> of server> 2000
> The zip file can be downloaded at
>    http://www.tabbyinstall.com/example-20090606.zip
> Kelly
Ok, got it. What you are trying to do is to close the session when you 
receive a specific message (PtServer_3). That's fine except that if you 
close the session which is processing the disconnecting packet, then the 
client will close the session, leaving the NioConnector alive, and doing 
nothing. This is why it seems to wait forever.

What really happens is that the session is closed when the timeout has 
expired (3 seconds).

The only way to close correctly the client is to register a listener in 
the closeFuture :
David Rosenstrauch has sent a mail where he explains the way to do that :

public class ShutdownCommand extends TextProtocolCommand {
        public ProtocolResponse execute() throws Exception {
                CloseFuture closeFuture = getSession().close(closeImmediately);
                closeFuture.addListener(new CloseSessionListener());
                return null;
        class CloseSessionListener implements IoFutureListener<CloseFuture>
                public void operationComplete(CloseFuture future) {

 public class CacheServer implements CacheServerControl {
        public void shutdown() {
                logger.debug("{} protocol processor shutting down server
 socket", protocolType);

        private String protocolType;
        private SocketAcceptor protocolAcceptor;
        private Logger logger;

Hope it helps.

cordialement, regards,
Emmanuel L├ęcharny

View raw message