Thursday, October 04, 2007

FastCGI File Upload error

This error was tough to track down. I have a really simple rails app running using mini_magick and FastCGI and Lighttpd. I got the following error when I tried to upload an image that was greater than 120K

[04/Oct/2007:19:33:42 :: 28348] Dispatcher failed to catch: protocol error (FCGI::Stream::ProtocolError)
/usr/local/lib/ruby/1.8/cgi.rb:980:in `read'
/usr/local/lib/ruby/1.8/cgi.rb:980:in `read_multipart'
/users/home/dazlus/web/public/../config/../vendor/rails/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb:20:in `initialize_query'
/usr/local/lib/ruby/1.8/cgi.rb:2275:in `initialize'
(eval):16:in `initialize'
/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:612:in `new'
/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:612:in `each_cgi'
/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:609:in `each'
/usr/local/lib/ruby/site_ruby/1.8/fcgi.rb:609:in `each_cgi'
/users/home/dazlus/web/public/../config/../vendor/rails/railties/lib/fcgi_handler.rb:53:in `process!'
/users/home/dazlus/web/public/../config/../vendor/rails/railties/lib/fcgi_handler.rb:23:in `process!'
almost killed by this error

Looking into it, there wasn't much on the web. I found some general posts about a cgi.rb issue with FastCGI that crashes for certain file types. I saw a couple posts about tmp directory file size limits. But neither was it. I then found some reports about FastCGI errors and Mongrel is recommended at, so I switched to Mongrel and I had no trouble afte that.