David Rosenstrauch a écrit :
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.
We will try to help ...
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?
Hmmm. If you brutally shutdowned the client, I'm afraid the socket will
remain in ESTABLISHED states for ever, accordingly to
http://www.cis.temple.edu/~ingargio/cis307/readings/tcpstates.gif, as
you haven't send any FIN segment.
May be checking for the socket idleness every X minutes could help to
close the orphan sockets ?