We're finally starting to put our MINA server into hard-core production
use, and came upon something weird today. Was hoping someone might have
some idea what's going on and/or have some suggestions for a solution.
For some reason MINA (or NIO or Java ...) seems to be hanging on to old
network connections and never letting go.
The client to our MINA server is another (apache httpd-based) custom
server we wrote. That server opens a bunch (2 dozen I think) of
long-lived connections to the MINA server (using some apache/apr
connection pooling utility). It keeps them open, and sends queries to
the MINA server periodically as needed.
The connection pool on the other server got messed up recently somehow,
so we shut down that daemon (and even rebooted that box). But MINA is
still holding onto a load of what it thinks are connections to that box.
(NIOSocketAcceptor.getManagedSessionCount() shows 175!) Similarly
netstat lists that many connections in the ESTABLISHED state, owned by
the java process - even though when I run netstat on the box on the
other side (which has been rebooted) it no longer shows all those
sockets open on its end.
Anyone know what might be going on here and/or how to fix? Why wouldn't
MINA be closing out those old connections?
We're running MINA 2.0.0-M6 on CentOS Linux 5.4 and OpenJDK 1.6.0.
Also potentially of relevance (though I think unlikely): in my code I'm
calling setReuseAddress(true) on the NioSocketAcceptor(). (This was to
work around an issue where if I shut down the server uncleanly (as I
often do when testing in development) the OS wouldn't let a new instance
of the MINA server re-bind to the server port.)
Any help much appreciated, cause I'm stumped!
Thanks,
DR