Hi everyone,

I'm porting a mina server implementation from 1.1.7 to 2.0.7 and I encountered 
the following issue:

When I replaced the IoAcceptor.unbindAll() method with 
NioSocketAcceptor.unbind(), the server didn't actually closed his connection 
anymore.

Old code (this worked):
    private IoAcceptor socketAcceptor;
    
    public void resetConnection( ) throws IOException, Exception
    {
        socketAcceptor.unbindAll( );
        openSocket(serverPort, msgType, gmsConfig, brokerConfig);
    }

I tried:
    private NioSocketAcceptor socketAcceptor;

 -  public void resetConnection( ) throws IOException, Exception
    {
        socketAcceptor.unbind( );
       ...
    }

 -  public void resetConnection( ) throws IOException, Exception
    {
        socketAcceptor.setCloseOnDeactivation(true);
        for (IoSession ss : socketAcceptor.getManagedSessions().values()) {
            ss.close(true);
        }
        socketAcceptor.unbind();
        socketAcceptor.dispose()
        ...
    }

 -  public void resetConnection( ) throws IOException, Exception
    {
        for (IoSession ss : socketAcceptor.getManagedSessions().values()) {
            ss.close(true);
            ss.getCloseFuture().awaitUninterruptibly();
        }

        socketAcceptor.unbind();
        socketAcceptor.dispose();
        ...
    }

The goal of this code is to reset the connection when the server receives a 
certain message. (The client should be disconnected and be allowed to reconnect 
afterwards)

In each of the tried versions, the code will never reach further than the 
provided lines. It always gets stuck waiting for the connection to be closed.
The last one gives me a CLOSE_WAIT in netstat but I already tried with several 
clients and I get the same result. 

Thanks in advance,

Wim



Reply via email to