OS X 上的 Apache Bench 测试错误:“apr_socket_recv:对等连接重置(54)”

ben*_*ben 57 apache-http-server osx-lion

几周前我将 MacBook Pro 13" 更新为 Lion。我刚刚发现 Apache Bench (apache2.2.19) 不起作用。它总是显示这个错误,无论如何:

apr_socket_recv:对等方重置连接(54)

我还在我的 Mac Mini 上进行了全新安装,但它产生了同样的错误。

我怎样才能解决这个问题?

小智 67

请注意,如果您-r与 Apache Bench 一起使用,它不会在出现错误时退出。

文档

-r
不要在套接字接收错误时退出。

  • 它应该除非它是错误的。我只是尝试运行:`ab -n 200 -c 20 -r http://localhost` 并得到(上帝禁止评论有换行符!)`测试在 10 次失败后中止 apr_socket_connect():操作已经在进行中 (37)共完成 4 个请求` (12认同)
  • 不幸的是它仍然存在 (3认同)

小智 47

这是由于与 Lion 捆绑的 Apache 软件中存在错误。较新版本的 Apache(测试版)修复了该问题。要修复 ab,请执行以下步骤:

  1. 下载最新版本的 Apache

    $ wget http://apache.mirrors.pair.com//httpd/httpd-2.3.16-beta.tar.bz2
    
    Run Code Online (Sandbox Code Playgroud)

如果 2.3.16 不可用,请访问http://apache.mirrors.pair.com/httpd并获取最新的

  1. 安装 pcre(你需要 brew 为此)

    $ brew install pcre
    
    Run Code Online (Sandbox Code Playgroud)
  2. 构建 Apache

    $ tar xzvf httpd-2.3.16-beta.tar.bz2
    $ cd httpd-2.3.16-beta
    $ ./configure
    $ make
    
    Run Code Online (Sandbox Code Playgroud)
  3. 用新建的 ab 覆盖现有 ab

    $ sudo cp support/ab /usr/sbin
    
    Run Code Online (Sandbox Code Playgroud)

  • 我正在对 node.js helloworld 应用程序进行基准测试。起初,我收到了任何“ab”基准测试的“对等(54)重置连接”。然后在完成上面的修复之后,我可以做`ab -n 100 -c 100`。然后我可以做`ab -n 200 -c 100`。我可以做`ab -n 200 -c 150`...当我在`-c 200`之上取`-c`时,有时它会执行,有时它会抛出一个`Connection Reset by Peer (54)`错误。这是不确定的。该怎么办? (3认同)
  • 运行`./configure`时,如果遇到`configure: error: C compiler cannot create executables`请看这篇文章:http://stackoverflow.com/a/11712497/599391 (3认同)

mma*_*may 5

链接上使用通过自制软件更新 ab 的方法对我有用。

brew install 'https://raw.github.com/simonair/homebrew-dupes/e5177ef4fc82ae5246842e5a544124722c9e975b/ab.rb'
brew test ab
Run Code Online (Sandbox Code Playgroud)

  • 欢迎使用超级用户!虽然这在理论上可以回答这个问题,但 [最好](​​http://meta.stackexchange.com/q/8259) 在此处包含答案的基本部分,并提供链接以供参考。 (2认同)

小智 5

您是否尝试使用:127.0.0.1而不是本地主机?

如果我不在http://前面写 url,我的 ab 也会失败。


pol*_*ial 0

有几件事需要测试:

  • 您可以尝试禁用防火墙看看是否有效?
  • 启用网络共享并测试 localhost/ (确保它首先在浏览器中工作)

如果这些都不起作用,你可以打开一个终端并

$ sudo opensnoop
Run Code Online (Sandbox Code Playgroud)

然后运行 ​​apache bench 并在问题中发布 opensnoop 终端的输出。如果这些都不起作用,你可以尝试安装 macports,然后从那里安装 apache,看看这是否可以作为解决方法(有点蹩脚)。

我的Air是lion的,但是apache版本不同(最近有更新,你已经安装了吗?)。我能够验证 ab 对我有用:

$ ab -V
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
$ uname -a
Darwin air.local 11.1.0 Darwin Kernel Version 11.1.0: Tue Jul 26 16:07:11 PDT 2011; root:xnu-1699.22.81~1/RELEASE_X86_64 x86_64
$ ab google.com/ 
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking google.com (be patient).....done


Server Software:        gws
Server Hostname:        google.com
Server Port:            80

Document Path:          /
Document Length:        219 bytes

Concurrency Level:      1
Time taken for tests:   4.130 seconds
Complete requests:      1
Failed requests:        0
Write errors:           0
Non-2xx responses:      1
Total transferred:      511 bytes
HTML transferred:       219 bytes
Requests per second:    0.24 [#/sec] (mean)
Time per request:       4130.343 [ms] (mean)
Time per request:       4130.343 [ms] (mean, across all concurrent requests)
Transfer rate:          0.12 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:     4119 4119   0.0   4119    4119
Processing:    11   11   0.0     11      11
Waiting:       11   11   0.0     11      11
Total:       4130 4130   0.0   4130    4130
Run Code Online (Sandbox Code Playgroud)