How do I remove a CLOSE_WAIT socket connection

后端 未结 7 900
庸人自扰
庸人自扰 2020-12-04 05:38

I have written a small program that interacts with a server on a specific port. The program works fine, but:

Once the program terminated unexpectedly, and ever since

7条回答
  •  情深已故
    2020-12-04 05:50

    I'm also having the same issue with a very latest Tomcat server (7.0.40). It goes non-responsive once for a couple of days.

    To see open connections, you may use:

    sudo netstat -tonp | grep jsvc | grep --regexp="127.0.0.1:443" --regexp="127.0.0.1:80" | grep CLOSE_WAIT
    

    As mentioned in this post, you may use /proc/sys/net/ipv4/tcp_keepalive_time to view the values. The value seems to be in seconds and defaults to 7200 (i.e. 2 hours).

    To change them, you need to edit /etc/sysctl.conf.

    Open/create `/etc/sysctl.conf`
    Add `net.ipv4.tcp_keepalive_time = 120` and save the file
    Invoke `sysctl -p /etc/sysctl.conf`
    Verify using `cat /proc/sys/net/ipv4/tcp_keepalive_time`
    

提交回复
热议问题