2 TCP Kill
tengel edited this page 2024-09-05 08:27:27 -05:00

Killing a stalled TCP connection

Requires: kernel >= 4.9 with CONFIG_INET_DIAG_DESTROY

Scenario: subprocess rclone has encountered trouble and started to stall out, running at a severely decreased rate of speed

Task: pause rclone, kill the in-progress TCP connection, resume rclone which will trigger it to (re)create a new, working TCP connection (app dependent)

Steps

Find the process and it's TCP stalled connection:

$ ps axo pid,comm | grep [r]clone
  6874 rclone

$ ss -ntp | grep [r]clone | awk '{print $5, $6}'
74.120.9.121:443 users:(("rclone",pid=6874,fd=9))

Pause the process, kill the connection (as root), resume the process:

$ kill -STOP 6874

$ sudo ss -K dst 74.120.8.14 dport 443

$ kill -CONT 6874