Le 6/25/13 1:43 PM, Wim Verreydt a écrit :
> 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)
Why don't you do a session.close() when you receive the special message ?
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com