[erlang-questions] Why does having SNDBUF too low break HTTP?
Wed Nov 21 19:51:55 CET 2012
I've got a simple http server running, with gen_tcp options as follows:
With one response in particular that sends a single 300000 byte http chunk
with a single gen_tcp:send call, I'm seeing some clients failing to receive
it, or only receiving the first 150000 - 250000 bytes.
Firefox, Chrome and Cocoa's NSURLConnection all have problems while
receiving the response, with Firefox and NSURLConnection truncating the
response, and Chrome not accepting it at all and giving an error. Curl and
wget however receive the response fine.
tcpick -C -yP "tcp port 80" shows the connection being closed before all
the data's sent, printing the data truncated at the same place as Firefox,
1 FIN-WAIT-2 x.108.161.x:65438 > 10.144.11.241:http
1 TIME-WAIT x.108.161.x:65438 > 10.144.11.241:http
1 CLOSED x.108.161.x:65438 > 10.144.11.241:http
Setting sndbuf to 512000 however seems to solve the problem, at least for
the 300000 byte chunk size I'm sending.
Why would sndbuf affect the validity of the TCP/HTTP stream? Someone
suggested this looks like the return value of write(2) isn't being checked,
or EAGAIN isn't being dealt with correctly? gen_tcp:send is returning ok,
Erlang version: Erlang R15B02 (erts-5.9.2) [source] [64-bit]
[async-threads:0] [hipe] [kernel-poll:true]
Any ideas what could be causing this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions