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

[Bug]: Keepalive 设置不生效 #492

Closed
3 tasks done
iqinlongfei opened this issue Aug 4, 2023 · 3 comments
Closed
3 tasks done

[Bug]: Keepalive 设置不生效 #492

iqinlongfei opened this issue Aug 4, 2023 · 3 comments
Assignees
Labels

Comments

@iqinlongfei
Copy link

iqinlongfei commented Aug 4, 2023

Actions I've taken before I'm here

  • I've thoroughly read the documentations on this issue but still have no clue.
  • I've searched the Github Issues but didn't find any duplicate issues that have been resolved.
  • I've searched the internet for this issue but didn't find anything helpful.

What happened?

TCP Server设置了5秒的KeepAlive时间,gnet.WithTCPKeepAlive(5*time.Second),在压测时,Client与Server大概建立了8000+条TCP连接,Client在运行中crash掉了,但Server端并没有按照设置的KeepAlive断开连接。

看了一下源码,TCP_KEEPINTVL和TCP_KEEPIDLE设置了5s,TCP_KEEPCNT没有设置,系统设置的是9。所以总的断开时间应该是5 + 5*9 = 50s。也就是说50s后,server端会断开连接。
image

但我抓包看,server端并没有发送keepalive,而是每隔120s进行一次重传。65.78是server,65.79是client
image

Major version of gnet

v2

Specific version of gnet

v2.3.0

Operating system

Linux

OS version

Linux 5.4.56.bsk.9-amd64 x86_64

Go version

go version go1.18.2 linux/amd64

Relevant log output

没有设置logger

Code snippets (optional)

No response

How to Reproduce

  1. server设置Keepalive时间5s
  2. server与client建立1000条TCP连接。
  3. client端crash,确保不发送REST/FIN。测试时client通过XDP+用户态TCP协议栈,在crash时不会给server端发送RESET。
  4. 发现server端会保持1000条连接很长时间而且期间抓包也没有看到Keepalive报文

Does this issue reproduce with the latest release?

I haven't verified it with the latest release

@iqinlongfei iqinlongfei added the bug Something isn't working label Aug 4, 2023
@panjf2000
Copy link
Owner

能提供一下可以复现这个问题的客户端和服务端代码吗?

@iqinlongfei
Copy link
Author

代码需要整理一下,需要提取出来

@panjf2000 panjf2000 changed the title [Bug]: Keepalive不work [Bug]: Keepalive 设置不生效 Aug 4, 2023
@panjf2000
Copy link
Owner

最近 gnet 对 TCP Keep-Alives 设置做了以下优化: #522,可以验证一下这个问题是否存在,我先关闭 issue 了,如果还有问题可以随时重新打开这个 issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants