Hi there,
I'm having a problem with one of my applications. It's a high concurrency NIO (as in New IO packages, java.nio.*) based java server. The issue we're having is that if clients do not gracefully close the connection the server leaks file descriptors. We also have an excessive number of connections in CLOSE_WAIT state during this.
There was a known (and resolved) bug for this pre 1.5.07 : http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6215050
All fixed mentioned in this bug report do not solve this problem. The code to close the socket on the server end is as follows (yes i know it's overkill :) ) :
/* Close socket channel */
try { socketChannel().socket().getInputStream().close(); } catch (Exception e) {}
try { socketChannel().socket().getOutputStream().close(); } catch (Exception e) {}
try { socketChannel().socket().shutdownInput(); } catch (Exception e) {}
try { socketChannel().socket().shutdownOutput(); } catch (Exception e) {}
try { socketChannel().socket().close(); } catch (Exception e) {}
socketChannel().close();
This code is called for all connections that are closed, including the ones causing the leak. Is there anything I'm missing here? Information or suggestions would be greatly appreciated.
Regards,
Remon