Post by luckyb333 » Sat Jul 23, 2011 10:28 am

I just did a clean install of v1.5.0
This is my first time using opencart and I'm loving it but I've got one huge problem. I sell downloadable videos and the files are all very large. Anytime I try to download one it stops at around 100MB. Splitting them up is not an option BTW. Researching the problem here it was clear it was an issue with my host so i contacted their support. Below is the message I received.
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 you may
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:

http://codeutopia.net/blog/2009/03/06/s ... e-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.
I'm not completely clueless when it comes to this stuff but I'm in over my head here. Can anyone tell me if this is a possible fix for me and if so, give me fairly simple instructions on what I need to change in opencart to make it work?

Thanks in advance for helping the noob(even if it is just to tell me I'm screwed),


Keith

Newbie

Posts

Joined
Sat Jul 23, 2011 9:44 am

Post by marcelwoo » Sat Jul 23, 2011 1:59 pm

bump:)

"We help each other to grow". That's the opencart community!

All free mods
Home Based Ebay business Opportunity(not ads)


User avatar
Active Member

Posts

Joined
Tue Mar 29, 2011 1:45 am

Post by Xsecrets » Sat Jul 23, 2011 2:12 pm

well basically you have two options use xsendfile which is probably the best option for you, but not a good option for opencart as a whole since most hosts don't have that mod installed in apache. two is to send the file in chunks instead of all at once which may be a better solution for opencart overall if Daniel even wants to bother.

for xsendfile I haven't tested this, so I can't say weather it works or not as I don't have a server with xsendfile, but according to what I've read it should work.

in catalog/controller/account/download.php find

Code: Select all

                if (file_exists($file)) {
                    header('Pragma: public');
                    header('Expires: 0');
                    header('Content-Description: File Transfer');
                    header('Content-Type: ' . $mime);
                    header('Content-Transfer-Encoding: ' . $encoding);
                    header('Content-Disposition: attachment; filename=' . ($mask ? $mask : basename($file)));
                    header('Content-Length: ' . filesize($file));
                
                    $file = readfile($file, 'rb');
                
                    print($file);
                } else {
 
and change it to

Code: Select all

                if (file_exists($file)) {
                    header('Pragma: public');
                    header('Expires: 0');
                    header('Content-Description: File Transfer');
                    header('Content-Type: ' . $mime);
                    header('Content-Transfer-Encoding: ' . $encoding);
                    header('Content-Disposition: attachment; filename=' . ($mask ? $mask : basename($file)));
                    header('Content-Length: ' . filesize($file));
                    header('X-Sendfile: ' . $file);
                } else {
 

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by luckyb333 » Sat Jul 23, 2011 3:16 pm

Thanks a lot Xsecrets.
My hosting company has to do something first but once they do I'll cross my fingers and give it a try.
I'll report back one way or another after I've tested it thoroughly.

Newbie

Posts

Joined
Sat Jul 23, 2011 9:44 am

Post by luckyb333 » Sun Jul 24, 2011 1:34 am

Well, that didn't seem to work unfortunately.
It brings up the save dialog and the file name is correct but when I actually click save the download manager pops up for a split second and then goes away. I end up with a 0kb file. I've contacted my host again just to have them make sure the xsendfile module was actually added to my domain correctly but unless that's the case I can't see why that wouldn't have worked.

Any other idea's?

Newbie

Posts

Joined
Sat Jul 23, 2011 9:44 am

Post by luckyb333 » Sun Jul 24, 2011 7:44 am

Since there didn't seem to be any reason that shouldn't have worked I contacted my hosting company and sure enough, the mod hadn't been installed correctly. They fixed it and now it's working perfectly and I'm able to download large files with no problem. The only downside is that of course the shopping cart now has no way to know if the download was successful or not so as soon as it's started the cart software assumes it's been downloaded. Not too big of a deal though.

Thanks a million for the help with the code Xsecrets!

Newbie

Posts

Joined
Sat Jul 23, 2011 9:44 am

Post by TraderDan » Tue Mar 13, 2012 10:46 am

I am basically having the same problems, and will be contacting my host in hopes of implementing the xsendfile method of download delivery.

In the meantime, I was hoping someone could shed a little light as to why this is such a problem with OpenCart when I never had a single problem vending large downloads with Zen Cart? Don't get me wrong, I absolutely love OC and would not dream of ever going back to ZC, but I never once had this problem until switching. How is it that, with the same host company, ZC could vend these large downloads without incident and yet OC has so many problems?

Any further insight is greatly appreciated, thanks.

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by wendy2009 » Tue Mar 13, 2012 11:06 am

ImageThanks a lot.

Newbie

Posts

Joined
Tue Mar 06, 2012 11:36 am

Post by Afshispeaks » Tue Mar 13, 2012 4:14 pm

Thanx for informative information.

Newbie

Posts

Joined
Tue Mar 13, 2012 4:06 pm


Post by TraderDan » Fri Mar 16, 2012 2:11 am

Anyone? Bueller...?
TraderDan wrote:How is it that, with the same host company, ZC could vend these large downloads without incident and yet OC has so many problems? Any further insight is greatly appreciated, thanks.

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by Qphoria » Fri Mar 16, 2012 4:09 am

TraderDan wrote:Anyone? Bueller...?
TraderDan wrote:How is it that, with the same host company, ZC could vend these large downloads without incident and yet OC has so many problems? Any further insight is greatly appreciated, thanks.
This is zencarts download code converted for opencart variables:

Code: Select all

    header("Content-Type: application/force-download");
    header('Content-Disposition: attachment; filename="' . ($mask ? $mask : basename($file)) . '"');
    header("Content-Length: " . filesize($file));
    header("Expires: 0");
    header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by TraderDan » Tue Mar 20, 2012 6:56 pm

Thanks Q, it looks like I have no other option but to try it. I submitted a request ticket to BlueHost to have the X-SENDFILE mod installed on the server hosting my Reseller account and they just denied me... not happy. This is what they wrote:
BlueHost Level III Tech Support wrote:In reviewing the module in question, there doesn't appear to be any significant advantage to this module, while it does in fact introduce a whole slew of headaches for server security and the sandboxing that we employ for customer accounts.

I would expect that the issues you are seeing currently are not due to instabilities in Apache's normal file serving methods, but are instead the result of our resource management daemons which will terminate running processes after a period of time. Currently the limit for a Webserver based process is 10 minutes. After a website process exceeds 10 minutes, it will be terminated, which is born out in our logs where it appears that the resource daemon has been regularly encountering long running Apache processes for your account which have had to be terminated after 600 Seconds (10 minutes.)

I'm afraid that an alternate Apache module for serving files will not work around this limit, it is hard-coded into the server kernel that certain processes should only be allowed to operate for predetermined periods of time.
Last edited by TraderDan on Tue Mar 20, 2012 9:35 pm, edited 1 time in total.

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by TraderDan » Tue Mar 20, 2012 9:45 pm

I can confirm that if I download files directly from my server (without going through OpenCart at all), I can download a giant 1GB file without incident, taking roughly 30 minutes to complete. That same file however will fail every time if I download through OpenCart because of the hard 10-minute limit imposed by BlueHost for a "Webserver based process."

Well OK, since Zen Cart doesn't appear to kick off a Webserver based process when it delivers purchased downloads, I never experienced this particular problem during the 2 years I used it to vend digital products. As a result of this, I attempted to swap in the Zen Cart-adapted code that Qphoria was kind enough to post, but unfortunately it has not solved my problem. The OC download is still kicking off some PHP script(s) or other Webserver based process(es) and is thus hindered by the 10-minute limit. So that leaves me with the following question:

What other edits to the code do I have to make to ensure that the download delivery is completely independent of Webserver based processes? And, what functionality am I ultimately sacrificing in order to have this? I can guess one caveat is not being able to verify complete downloads, thus the store doing a poor job of calculating remaining downloads. What else though?

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by Qphoria » Wed Mar 21, 2012 1:12 am

zencart does a "Webserver process" all the same.. anything from the http side will do it. Their code is functionally equivalent for the most part.

Copying files from your ftp doesn't count because that is a direct connection with no server processing. You could do that all day.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by TraderDan » Wed Mar 21, 2012 1:17 am

Qphoria wrote:zencart does a "Webserver process" all the same.. anything from the http side will do it. Their code is functionally equivalent for the most part.

Copying files from your ftp doesn't count because that is a direct connection with no server processing. You could do that all day.
I wasn't downloading the test file via ftp, but downloading it directly via http, which yes, I can do all day outside of Open Cart. But apparently Zen Cart too can do it all day on the same server, so obviously the two carts do not handle downloads the same way. Anyone want to take another stab at it?

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by Qphoria » Wed Mar 21, 2012 1:23 am

How are you downloading it "all day" ? just going directly to the file with http://mysite.com/download/filename.zip ?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by TraderDan » Wed Mar 21, 2012 1:32 am

Qphoria wrote:How are you downloading it "all day" ? just going directly to the file with http://mysite.com/download/filename.zip ?
Yes, exactly right. That's what I did to make sure that, on my current host account for OC, I could spend more than 10 minutes downloading a large file if there were no processes attached.

And with the same host company (different shared account) I have my now-defunct Zen Cart installation. For two years I was vending these same huge files and never once received a customer complaint about downloading issues. When ZC kicks off a download, it's essentially an encrypted http link, and the download can pretty much take as long as it needs. I admit my understanding of all this is incredibly limited, but from what I've observed I can only conclude that these so-called "Webserver processes" are not involved with a ZC download, or at least more specifically, they are not engaged for the full duration of the download.

Therefore, due to differences in how the two platforms manage downloads, ZC downloads had been successful virtually 100% of the time while OC downloads are only successful if they take no more than 10 minutes. Based on current sales data of my digital products, this comes out to a roughly 65% success rate with my OC downloads, and that's just not acceptable for my business. I realize I may very well wind up having to migrate to another host, but I would love to figure out a way around this issue if possible, and the differences I've observed when compared to ZC seems to be a worthwhile starting pointing.

Image


User avatar
New member

Posts

Joined
Thu Oct 27, 2011 10:44 pm
Location - Lawrence, MA

Post by gmedia01 » Thu Dec 13, 2012 7:00 pm

Which method is best? We have a VPS with full access to Apache. It seems like the mod_xsendfile will be easy to install, but it is a little unclear to me how to do that in WHM. I need to search more.

Also, I'm not sure what to do with the code you posted Qphoria. Can you elaborate?

So the options are:
1. mod_xsendfile
2. Qphoria zendcart code
3. Purchase extension like: http://www.opencart.com/index.php?route ... on_id=7201
4. Cry

Please do not select option 4.

Thanks ahead of time for the hep!

Chris

New member

Posts

Joined
Sun Aug 26, 2012 4:49 am

Post by gmedia01 » Thu Dec 13, 2012 9:07 pm

Also, can someone walk me through how to install any of the files for the mod here: https://tn123.org/mod_xsendfile/


I can download the files just fine to my local PC. I'm not sure which file is best, but I assume they are pretty much the same except for the method used to zip/compress the file.

How do I get the mod_xsendfile I just downloaded UPLOADED to Apache so I can use SSH to install it?

I may not even know what I'm talking about enough to ask intelligently. :)

Most tutorials will say something like this...

1. Grab the source.
2. Compile and install
apxs -cia mod_xsendfile.c
3. Restart apache

I gather that it is simple, but step 2 assumes a lot of foreknowledge. What does Compile and Install mean exactly (steps)? We are running the latest stable release of Apache (2.22 I think).

I also don't know how to enable apxs or apsx2, figure out if they are already enabled, or know which is better.

I know. That's a lot, but I'm putting it here for all to know.

Chris

New member

Posts

Joined
Sun Aug 26, 2012 4:49 am

Post by gmedia01 » Sat Dec 22, 2012 12:39 am

Ouch!

That hurts!

Chris

New member

Posts

Joined
Sun Aug 26, 2012 4:49 am
Who is online

Users browsing this forum: Semrush [Bot] and 217 guests