Mikhail Nikalyukin
Mikhail Nikalyukin

Reputation: 11967

rails ajax file upload and nginx

I'm using Rails and valums file-uploader for ajax upload. In development all works flawlessly, however in production on linode nginx breaks things. Error log:

[ pid=2097 thr=3065629552 file=ext/nginx/HelperAgent.cpp:584 time=2011-06-23 09:47:06.714 ]: Uncaught exception in PassengerServer client thread:    exception: An error occured while sending the request body to the request handler: Broken pipe (32)    backtrace:
     in 'virtual void Passenger::Session::sendBodyBlock(const char*, unsigned int)' (Session.h:198)
     in 'void Client::sendRequestBody(Passenger::SessionPtr&, Passenger::FileDescriptor&, const std::string&, long unsigned int)' (HelperAgent.cpp:295)
     in 'void Client::handleRequest(Passenger::FileDescriptor&)' (HelperAgent.cpp:510)
     in 'void Client::threadMain()' (HelperAgent.cpp:603)

2011/06/23 09:47:06 [error] 2134#0:
*13 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 94.76.87.38, server:
69.168.213.69, re$

Upload is working fine without javascript, using rails 3 and paperclip. Database - PostgreSQL. I'm really low at server-side stuff and looking help how to fix that. If you need additional information please leave a comment.

Upvotes: 2

Views: 1040

Answers (1)

Mikhail Nikalyukin
Mikhail Nikalyukin

Reputation: 11967

File upload works through StringIO on webbrick, but through Rack on everything but webrick. Those changes fixed an issue for me:

-    file = request.body
+    file = StringIO.new(request.body.read)

Upvotes: 3

Related Questions