< 返回版块

xcaptain 发表于 2019-03-31 19:35

前段时间我在写我自己的web框架,在做压力测试的时候发现了

failed to process connection; error = Os { code: 104, kind: ConnectionReset, message: "Connection reset by peer" }

这样的错误,经过一番搜索之后发现了 https://github.com/tokio-rs/tokio/issues/383 这个issue,应该是mio硬编码了backlog导致的,今天有空我通过 cargo edit locally把mio代码复制到项目下修改backlog为128之后再测试不出现上面那个错误了

在2017年就有人尝试修复这个问题但是被搁置了 https://github.com/carllerche/mio/pull/623,对网络底层有兴趣的大佬麻烦确认下这个问题修一下吧

评论区

写评论
作者 xcaptain 2019-04-01 00:11

mio用的就是net2但是设置的最大backlog写死为1024了,应该要从 /proc/sys/net/core/somaxconn 这个文件读,一般这个文件的值是128

对以下内容的回复:

使用net2即可

[https://docs.rs/net2/0.2.33/net2/struct.TcpBuilder.html#method.listen](https://docs.rs/net2/0.2.33/net2/struct.TcpBuilder.html#method.listen)
1 共 2 条评论, 1 页