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

client connection has been closed by peer #363

Open
lkxiaolou opened this issue Oct 10, 2024 · 5 comments
Open

client connection has been closed by peer #363

lkxiaolou opened this issue Oct 10, 2024 · 5 comments

Comments

@lkxiaolou
Copy link

lkxiaolou commented Oct 10, 2024

Describe the bug
仅使用 netpoll client 进行建连,当 server 设置 ReadTimeout 比较小时,例如这样:

// server
func main() {
	s := http.Server{
		ReadTimeout: time.Millisecond,
	}

	ln, err := net.Listen("tcp", ":8000")
	if err != nil {
		panic(err)
	}
	s.Serve(ln)
}

// client
dialer := netpoll.NewDialer()
conn, err := dialer.DialTimeout("tcp", "127.0.0.1:8000", 2*time.Second)

client 压力大,调度慢时出现 client connection has been closed by peer 报错,原生 net 则不会

@huzhao37
Copy link

huzhao37 commented Oct 10, 2024 via email

@joway
Copy link
Member

joway commented Oct 11, 2024

@lkxiaolou “原生 net 则不会” 是没有这个报错还是其他报错?从你的代码看,server 在 1 ms 内没有收到请求就要关闭连接,所以netpoll 报这个错误是符合预期的?
image

@joway
Copy link
Member

joway commented Oct 11, 2024

一般你作为 server,这个值就不应该设置成 1ms 这么小

@lkxiaolou
Copy link
Author

一般你作为 server,这个值就不应该设置成 1ms 这么小

后续读写报错符合预期,但建立连接不应该报错

@joway
Copy link
Member

joway commented Oct 24, 2024

@lkxiaolou #364 可以试试看这个分支是否还有你的这个问题吗?

@zjbpaul1317 zjbpaul1317 mentioned this issue Dec 18, 2024
3 tasks
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

3 participants