1

I found a problem on my web application, hibernate connections does not close properly. but given the complexity of the web application, it takes at least 15 - 30 days.

In the meantime I wanted to manually close the connection.

In that way I can close this connection without restart tomcat? There is a command that I can use for kill this pool of connection?

I have found an error in hibernate configuration, to solve

#netstat -anp |grep 3306 |grep CLOSE_WAIT
tcp        1      0 ::ffff:172.18.11.4:50750    ::ffff:172.18.11.8:3306     CLOSE_WAIT  4203/java           
tcp        1      0 ::ffff:172.18.11.4:36192    ::ffff:172.18.11.8:3306     CLOSE_WAIT  4203/java           
tcp        1      0 ::ffff:172.18.11.4:36215    ::ffff:172.18.11.8:3306     CLOSE_WAIT  4203/java           
tcp        1      0 ::ffff:172.18.11.4:36211    ::ffff:172.18.11.8:3306     CLOSE_WAIT  4203/java           
tcp        1      0 ::ffff:172.18.11.4:57820    ::ffff:172.18.11.8:3306     CLOSE_WAIT  4203/java           
tcp        1      0 ::ffff:172.18.11.4:36213    ::ffff:172.18.11.8:3306     CLOSE_WAIT  4203/java           
tcp        1      0 ::ffff:172.18.11.4:36159    ::ffff:172.18.11.8:3306     CLOSE_WAIT  4203/java 

etc....

CentOS 6.0 running Tomcat 5.5 and Mysql 5.5.

Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124
Gamin Goal
  • 11
  • 1
  • 1
  • 4

2 Answers2

1

Always call socket.close(). See also how to close JDBC resources properly every time.

If you can't fix the server, add the following lines to /etc/init.d/inetinit

/usr/sbin/ndd -set /dev/tcp tcp_close_wait_interval 1500
/usr/sbin/ndd -set /dev/tcp tcp_keepalive_interval 1500

and reboot. According to http://www.experts-exchange.com/OS/Unix/Solaris/Q_20568402.html

Alternatively, on Linux, try tcpkill (part of dsniff) or cutter.

Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124
0

There was some other question about this I can't find now. But you can try killcx and cutter. I can't find a link to cutter but it's found in debian repos. Make sure to pick the tcp connection killer and not the unit testing framework with same name.

update: there seems to be a windows version wkillcx update2: thanks Xiong Chiamiov for cutter link

akostadinov
  • 17,364
  • 6
  • 77
  • 85