PHP Upload Timeouts (Connection Reset)


#1

Okay, so the issue I’m having is that users are suffering “connection reset” or similar errors while uploading files to my phpBB forum. The uploads aren’t especially large, but the users suffering issues don’t have amazing upload speeds, still not uncommon really.

Anyway, best I can tell they’re hitting some kind of timeout but I’ve been having trouble figuring out where. It’s definitely not from PHP as the post and file size limits are high enough, no limit on input time, and RAM use and execution time shouldn’t be the issue (I only need to process file headers), plus iirc a PHP issue should at least return a more specific error message, rather than simply timing out?

I currently have PHP running as fast CGI, but I’m not sure if that’s the culprit or not; does it have any associated timeouts that could be affecting it?

Support mentioned that I can’t change fast CGI limits on a managed server, but should instead switch to standard CGI. Aside from being at a loss as to whether fast CGI is actually causing the issue, I’m unsure whether switching to CGI is a good idea? I have plenty of RAM on my VPS, and iirc you can only use persistent database connections under fast CGI, which I’ve found to be a significant benefit to my forums (after a few tweaks), plus as I understand it fast CGI has plenty of other benefits.

I’m sure other sites must be using PHP scripts that can accept large (or rather, slow) uploads, but are these running under CGI or should Fast CGI be innocent in this case?

The only other culprit I can think of is CloudFlare which I have enabled; uploads to my forum are well below the 100mb limit that CloudFlare will handle for POST requests, but I’m not sure if they have any timeouts? I’ve e-mailed their support as well, but haven’t got an answer on timeouts yet.


#2

Well when that appears, it’s always because of large files are being uploaded. Maybe you just input the wrong php codes in the wrong path? Instead of apache, I think it should be in php.ini or something.


#3

Some PHP.INI settings to try:

max_execution_time = 300
max_input_time = -1
post_max_size = 10M
upload_max_filesize = 10M

max_execution_time = n – counter in seconds begins at start of script execution.
max_input_time = n – counter in seconds begins once the data is uploaded to the server.
post_max_size & upload_max_filesize = nM – upload maximum in Megabytes.

FastCGI is killed off after 5 minutes or so. If the troublesome uploads are taking longer than 300 seconds then you should implement something more robust than PHP uploading.