Closed niukey closed 8 years ago
So, I've been looking at this problem for a while now. It's actually a little more strange than first expected.
Apache benchmark (ab) runs into a timeout, because it is still waiting for more data from the server.
The question is.. why? I've taken a look at the response returned from the server, and it
$ curl -si http://127.0.0.1:8080/foo | cat -A
HTTP/1.1 200 OK^M$
Server: Example^M$
Content-Length: 0^M$
Date: Wed, 31 Aug 2016 10:36:34 ^M$
^M$
It's the correct \r\n protocol line endings throughout the headers, and there's a \r\n separator for the body. Indeed, in this example, the Content-Length really is 0. I've tried manually hacking a different response in, and that doesn't work either.
Other normal tools like curl, wget, and web browsers seem to work fine.
As far as I can tell, this is either a bug in ab, or a specific odd interaction with ab.
impl Service for HelloWorld { type Req = http::Request; type Resp = http::Response; type Error = io::Error; type Fut = Finished<http::Response, io::Error>;
fn call(&self, _request: http::Request) -> Self::Fut {
let mut resp = http::Response::new();
resp.header("Connection","Keep-Alive");
futures::finished(resp)
}
} add resp.header("Connection","Keep-Alive"); it will be ok. thanks , : )
@niukey I've added that header. Now ab works, but ONLY when using "-k", which enables ab to understand keepalive. I don't understand how other servers work with this. If I netcat or telnet to my apache server, the connection will remain open until I close it. On that same server, ab works just fine. It only hangs on this server.
I could believe that ab has some weirdness in response handling, but I don't understand what it's reacting to. I don't believe we have completely found the root of this issue.
when not using "-k" , header need "resp.header("Connection","close");". server send the buffer to ab, and then close the connection. but I don't known how to close the connection is the example. : (
I was stuck at the exact same problem! if I knew how, I would try to implement it :)
F:\tokio-minihttp\target\debug\examples> cargo run --example hello_world Compiling tokio-minihttp v0.1.0 (file:///F:/tokio-minihttp) Running
.\hello_world.exe
but D:\Apache24\bin>ab -c 1 -n 100 -k http://127.0.0.1:8080/ nothing happen ,