Hi,
I have a server written using Mina with the NIO socket acceptor. When I
shutdown the server I call unbind and dispose on the acceptor as follows,
@Destroy
public void stop() throws InterruptedException {
for (IoSession session : acceptor.getManagedSessions().values()) {
session.close(false).await();
}
acceptor.unbind();
acceptor.dispose();
}
However, on OSX if I immediately try to restart the server, it throws a bind
exception stating address is already in use. On Solaris, I am unable to
restart the server at all without bouncing the box. Below is the code I use
to start the server,
@Init
public void start() throws IOException {
ExecutorService filterExecutor = new
SCA4JExecutorService(workScheduler);
InetSocketAddress socketAddress;
if (listenAddress == null) {
socketAddress = new
InetSocketAddress(InetAddress.getLocalHost(), commandPort);
} else {
socketAddress = new InetSocketAddress(listenAddress,
commandPort);
}
acceptor = new NioSocketAcceptor();
SocketSessionConfig config = acceptor.getSessionConfig();
config.setIdleTime(IdleStatus.READER_IDLE, idleTimeout);
acceptor.getFilterChain().addLast("threadPool", new
ExecutorFilter(filterExecutor));
acceptor.getFilterChain().addLast("codec", new
ProtocolCodecFilter(codecFactory));
acceptor.setHandler(ftpHandler);
monitor.extensionStarted();
acceptor.setCloseOnDeactivation(true);
acceptor.bind(socketAddress);
monitor.startFtpListener(commandPort);
}
Any pointers would be highly useful.
Kind regards
Meeraj