Recently, there has been a file upload timeout problem that many users on my system are experiencing. Basically, users log on to the upload system throughout the day and send files that are usually 1-3MB each in batches of usually 1-10 files. When the user uploads a file or batch for a certain amount of time, the file upload for dropzone fails with a message to the user "Server responded with 0 code". This problem only happens sometimes, but I can easily replicate the problem at any time if I try to upload a large file(s) that takes a few minutes to upload. I have searched and tried many things so far, but the problem still occurs.
If the upload succeeds, then the files are saved to a location on the server and information about each file is stored in the database.
The system is built with Laravel PHP, Dropzone.js, Mysql, and Apache. Below is some information about the error logs, configuration files, and things I've tried.
Here's what the laravel error logs are reporting after the upload fails:
[2014-10-02 15:52:26] log.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1429
Stack trace:
#0 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1050): Illuminate\Routing\Router->handleRoutingException(Object(Symfony\Component\Routing\Exception\ResourceNotFoundException))
#1 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1014): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(576): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#3 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(552): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#4 /usr/www/www.example.com/beta/public/index.php(49): Illuminate\Foundation\Application->run()
#5 {main} [] []
[2014-10-02 15:52:29] log.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' with message 'Controller method not found.' in /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Routing/Controllers/Controller.php:290
Stack trace:
#0 [internal function]: Illuminate\Routing\Controllers\Controller->missingMethod(Array)
#1 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Routing/Controllers/Controller.php(138): call_user_func_array(Array, Array)
#2 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Routing/Controllers/Controller.php(115): Illuminate\Routing\Controllers\Controller->callMethod('missingMethod', Array)
#3 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Routing/Router.php(985): Illuminate\Routing\Controllers\Controller->callAction(Object(Illuminate\Foundation\Application), Object(Illuminate\Routing\Router), 'missingMethod', Array)
#4 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Array)
#5 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Routing/Route.php(80): call_user_func_array(Object(Closure), Array)
#6 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Routing/Route.php(47): Illuminate\Routing\Route->callCallable()
#7 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1016): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#8 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(576): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#9 /usr/www/www.example.com/beta/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(552): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#10 /usr/www/www.example.com/beta/public/index.php(49): Illuminate\Foundation\Application->run()
#11 {main} [] []
Here's some settings for Apache (httpd.conf):
KeepAlive On
MaxKeepAliveRequests 500
KeepAliveTimeout 5
ServerLimit 513
MaxClients 100
MaxRequestsPerChild 10000
I have changed these settings in different ways like increasing the timeouts/maxclients to 500, but still the same results. The upload fails at a certain time and seems to ignore these settings completely.
Here's some settings in php.ini
default_socket_timeout = 500
mysql.connect_timeout = 500
max_execution_time = 1200
max_input_time = 1200
file_uploads = On
max_file_uploads = 50
post_max_size = 2047M
upload_max_filesize = 2047M
memory_limit = 258M
Here's the laravel .htaccess file
Options -Indexes
I have also tried changing the dropzone.js AJAX upload code by adding "xhr.timeout = 4000". By adding this line to dropzone.js, the upload will partially upload in the progress bar, but then it will never turn red and fail. The upload will just eternally pause, which leads me to think that the problem is somewhere on either laravel or the server, but I'm not sure at this point. Without this ilne of code, it seems to me that the AJAX request at some random time just gets dropped by the server/laravel and the file upload fails. What's even more strange to me is that this error just recently started happening. The system was running smooth and uploading files for months before this.
I would very much appreciate any brainstorming, feedback or help on this issue.
Thank you
UPDATE:
I added this line to my filters.php file to see what the missing route was...
App::missing(function($exception)
{
Log::error('Missing URL was: ' . Request::fullUrl());
});
I was able to remove all the "NotFoundHTTPException..." and "Controller method not found..." errors from my laravel error logs. However, the file upload still fails at a random time, but now there are no errors being reported in the laravel error logs. The dropzone ajax upload request just gets dropped at a random time and returns a status code 0.
Anyone have any ideas of what I should try next to fix this?