Fix for the stalled downloads in Leopard

2007/12/22

I was experiencing the occasional weird behaviour on downloading large files in Leopard: the download would stall, but after stopping/restarting (which can be done in Safari and iTunes), the download would continue. It was not very consistent, and I suspected the NAT router or even Rogers – some sites were occasionally having this problem, while other sites would not.

While playing with JRuby over the weekend, this happened again and pretty much prevented the gem installation – because the multi-megabyte gem index would not download from http://gems.rubyforge.org/. Strangely enough, same download would work on Tiger, on Linux and on Windows using same router – which pretty much excluded router as a cause.

I found simple fix here – big thanks to Chris D Searle. Run the following:

sudo sysctl -w net.inet.tcp.rfc1323=0

(it replaces the default value of 1)

I do not know all the details of the fix – it switches off some TCP window optimization which may have been the cause of the problem. More on the parameter and how to set it in variety of OS-es can be found in the TCP tuning handbook.

To make change permanent, create (or edit) the file /etc/sysctl.conf with the content:

net.inet.tcp.rfc1323=0