Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tcp 连接释放的不干净 #445

Open
Handgrip opened this issue Dec 23, 2022 · 5 comments
Open

tcp 连接释放的不干净 #445

Handgrip opened this issue Dec 23, 2022 · 5 comments

Comments

@Handgrip
Copy link
Contributor

Handgrip commented Dec 23, 2022

Platforms

CLI - Linux

Version

v2.5.0

Description

有很多连接没有释放,以下是重启录播姬后的链接情况,监听了6个直播间,重启后的连接是合理的。

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      1 127.0.0.1:38436    119.3.126.45:443        FIN_WAIT1   -
tcp        0      1 127.0.0.1:34466    114.116.243.39:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:51732    139.159.233.92:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:48298    119.3.126.45:443        FIN_WAIT1   -
tcp        0      1 127.0.0.1:57362    106.53.116.108:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:56334    119.3.126.45:443        FIN_WAIT1   -
tcp        0      1 127.0.0.1:49742    139.9.178.223:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:42262    139.9.79.50:443         FIN_WAIT1   -
tcp        0      1 127.0.0.1:44478    119.3.153.125:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:43598    139.9.51.12:443         FIN_WAIT1   -
tcp        0      1 127.0.0.1:60840    49.235.252.229:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:45034    139.9.51.12:443         FIN_WAIT1   -
tcp        0      1 127.0.0.1:42536    106.53.116.19:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:52036    114.116.243.39:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:40350    114.116.248.122:443     FIN_WAIT1   -
tcp        0      1 127.0.0.1:57592    120.79.130.50:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:45144    114.116.237.1:443       FIN_WAIT1   -
tcp        0      0 127.0.0.1:37600    114.116.243.39:2243     ESTABLISHED 4023643/BililiveRec
tcp        0      1 127.0.0.1:54064    106.53.116.108:443      FIN_WAIT1   -
tcp        0      0 127.0.0.1:59266    119.3.126.45:2243       ESTABLISHED 4023643/BililiveRec
tcp        0      1 127.0.0.1:48174    139.9.51.12:443         FIN_WAIT1   -
tcp        0      1 127.0.0.1:57934    114.116.250.11:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:40652    123.60.104.253:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:57366    119.3.125.51:443        FIN_WAIT1   -
tcp        0      1 127.0.0.1:47650    114.116.243.39:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:37882    139.159.233.92:443      FIN_WAIT1   -
tcp        0      0 127.0.0.1:59252    119.3.126.45:2243       ESTABLISHED 4023643/BililiveRec
tcp        0      1 127.0.0.1:58246    119.3.153.177:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:55034    119.3.153.177:443       FIN_WAIT1   -
tcp        0      0 127.0.0.1:40166    114.116.243.39:2243     TIME_WAIT   -
tcp        0      1 127.0.0.1:43714    120.92.158.137:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:47014    49.235.252.237:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:60326    49.232.64.2:443         FIN_WAIT1   -
tcp        0      1 127.0.0.1:59306    120.79.130.50:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:53758    114.116.231.8:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:33318    119.3.153.177:443       FIN_WAIT1   -
tcp        0      0 127.0.0.1:54812    114.116.231.8:2243      TIME_WAIT   -
tcp        0      0 127.0.0.1:44612    114.116.241.98:2243     ESTABLISHED 4023643/BililiveRec
tcp        0      0 127.0.0.1:59444    119.3.125.51:2244       ESTABLISHED 4023643/BililiveRec
tcp        0      1 127.0.0.1:47470    106.53.116.108:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:50632    106.53.116.19:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:40232    119.3.153.177:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:46936    114.116.231.8:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:57972    119.3.124.139:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:35280    49.235.235.254:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:57558    114.116.234.98:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:50614    139.9.77.36:443         FIN_WAIT1   -
tcp        0      1 127.0.0.1:52538    114.116.248.122:443     FIN_WAIT1   -
tcp        0      1 127.0.0.1:40226    119.3.153.125:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:51462    119.3.125.51:443        FIN_WAIT1   -
tcp        0      1 127.0.0.1:49162    114.116.250.11:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:53948    49.235.252.228:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:36708    49.235.235.254:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:33036    106.53.116.19:443       FIN_WAIT1   -
tcp        0      0 127.0.0.1:40860    119.3.125.51:2243       ESTABLISHED 4023643/BililiveRec
tcp        0      1 127.0.0.1:40956    106.53.116.10:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:34672    139.9.178.223:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:49974    114.116.227.57:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:42232    114.116.237.1:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:51332    114.116.231.8:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:56976    114.116.250.11:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:42756    120.92.158.137:443      FIN_WAIT1   -
tcp        0      1 127.0.0.1:46044    119.3.153.125:443       FIN_WAIT1   -
tcp        0      1 127.0.0.1:39310    114.116.248.122:443     FIN_WAIT1   -

Logs

No response

@Handgrip Handgrip changed the title tcp 链接释放的不干净 tcp 连接释放的不干净 Dec 23, 2022
@Genteure
Copy link
Member

我这里不能复现。

Quote:

The FIN_WAIT_1 state is waiting for the peer to ACK the FIN that this end has just sent. That outgoing FIN is subject to all the normal TCP retry and timeout processing, so if the other end has completely disappeared and never responds, TCP should time out the connection and reset it as a matter of course.

可能是因为你的 VPS 请求国内的B站服务器,断开连接时服务器发送的 ACK 丢包了导致握手流程没有完成。

可以参考一下这个 serverfault 问题:https://serverfault.com/questions/7689

@Handgrip
Copy link
Contributor Author

我这里不能复现。

Quote:

The FIN_WAIT_1 state is waiting for the peer to ACK the FIN that this end has just sent. That outgoing FIN is subject to all the normal TCP retry and timeout processing, so if the other end has completely disappeared and never responds, TCP should time out the connection and reset it as a matter of course.

可能是因为你的 VPS 请求国内的B站服务器,断开连接时服务器发送的 ACK 丢包了导致握手流程没有完成。

可以参考一下这个 serverfault 问题:https://serverfault.com/questions/7689

我放的 log 不是很好,抱歉;

重启之前是 ESTABLISHED,重启之后变成了 FIN_WAIT1;录播姬可能启动二十天了。

@Genteure
Copy link
Member

试一下在高级设置里把使用的网络换成 “系统”,默认应该是 “IPv4 和 IPv6” 或者 “全部” 忘了具体写的是什么了。

可以考虑之后把默认换成 “系统”。

@Handgrip
Copy link
Contributor Author

先改了试试,运行了4天,出现了一样的情况,详细日志会发邮箱里。感谢!

@Genteure
Copy link
Member

嗯。。应该不是上面说的那个。

.NET 的 HttpClient 会自动 KeepAlive,好像是默认保持时间是无限长。具体回头再仔细看一下。

@Genteure Genteure reopened this Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants