Large downloads timing out after about 5 minutes

Done a bit of searching on the forums, found a few leads, but not finding anything that works.

I have had a shared hosting plan since 2004 and recently I’ve had the need to host large files for download, so I switched to a VPS. I’m using the Wordpress “Paid Downloads” plugin and it’s been working OK, but I’ve run across some issues.

If I have a file, about 150mb, I can successfully download it if it takes less than 5 - 7 minutes. At home, I am able to download it no problem with a 12mbps cable connection. I’ve tried on my Android and have successfully downloaded the file while on WiFi, but on 3G, if it takes longer than 5 minutes (on average) the download stops and I get a size mismatch error. I’ve had others try and the issue persists with them as well. Chrome fails with no error, Firefox gives a size mismatch error as well as my Android with the default browser.

I’ve looked into the Timeout section of the httpd.conf file and this appears to be where the problem may lie. I’ve set the Timeout to 10 and the download consistently fails between 10 - 20 seconds. However, running into a snag, I’ve set the Timeout to 600 and also 9999 and it still fails between 5 - 7 minutes. I’ve restarted Apache, my VPS, and also made sure to disable Dreamhost Managed in my VPS settings, but I am still plagued by this problem.

Any insight or suggestions? I can also provide a test download link as well.

Thanks for your time.

A point to remember when connected via 3g that could screw up file transfers, especially large ones is that the devices IP address can change. (We ran into this issue keeping people logged in on a site, until we understood.) Basically as I understand it, anytime your devices changes towers the devices IP address will change. If you have good signal from two towers then can happen without moving far.

I completely understand. However, it also happens on my PC which is on a cable connection. Granted, I have a dynamic IP, but it does not change very often. As I said, if it takes longer than 5 minutes, the download fails. I’ve had it happen with a file that has downloaded successfully in the past just because my connection has been slow that night and it took longer to download.

Download with WorpPress go through php/script as do all plugins.
This has a very big LIMIT, since scripts only have a certain amount of time and amount of mb, after that they are automatticcally “cancelled”.
I got around it by putting my secure (.htaccess protected, with .htpasswd) outside of the wordpress folder and just setup direct links. The only dis-advantage is you will have to manually add users to the .htpasswd file to gain access.
There is no way around this, except maybe this what support gave me, but it was no solution for me.

You might want to consider looking into initiating your downloads with the Apache module mod_xsendfile.

Right now, your downloads are piping through a php script as it appears
you already know. The php script’s memory consumption increases
exponentially as the script is left open. Once the download is held open
for a while, the script hits our shared server’s memory limit and is
killed off. The memory limit is in place to keep our shared servers happy
and stable for you and other customers, so it’s not something I can
circumvent for you.

Utilizing mod_xsendfile in your download script will initiate the
download via HTTP, then close the php script so memory isn’t run up. It
also allows masking of the file location.

Here’s some more information on how to implement mod_xsendfile in your
download script: and-php/

Just follow the instructions under the “Sending files” section. If this
is something you’d like to implement for your domain, please let me know
in a reply to this email, as there are a few things I have to do from
this end.

Thanks ronthai! I modified the script to use XSendFile and it seems to be working like a champ! I’m currently at work, so the connection is slow, but it’s been going for almost 15 minutes and no timeouts. If anyone else cares to test, here’s a link to download:

It’s a dummy file I created with DD, so there’s nothing of importance in it. The MD5 is d8b61b2c0025919d5321461045c8226f.

No need to check, but would be awesome if you could :wink:

The download seems to work fine, very slow 45KB. I stopped the download after 10 minutes, saw no need to continue after that.
When downloading with download manager, 10 connection are set and I get 400-500KB and it says resume is supported.

Our site is running zen cart. how would i apply this to it? i have a little working knowledge, but would need a simple step by step if someone could assist.