I have a pretty nasty problem in my server application.
I associate Apache Mina with the following code:
acceptor.bind(new InetSocketAddress(PORT));
Where the acceptor is a NioSocketAcceptor. Through the HTTP interface, I can shut down the server to restart it.
Server.ioAcceptor.unbind(new InetSocketAddress(Server.PORT)); for(IoSession session: Server.ioAcceptor.getManagedSessions().values()){ if(session.isConnected() && !session.isClosing()){ session.close(false); } } Server.ioAcceptor.dispose(); Main.transport.stop(); Logger.getRootLogger().warn("System going down. Request from "+context.getRemoteAddress()); System.exit(10);
This is the code I use to stop the Mina server. However, if I try to start the server again in the next couple of minutes. (Somewhere between 5 and 15 minutes) When I start, I get the following exception: java.net.BindException: the address is already in use
I also tried a simple ioAcceptor.unbind (), but there was no difference. The server runs on Centos 5 with OpenJDK. Apache Mina 2.0 RC1 version.
Thanks in advance for any ideas on how to resolve this.
source share