views:

278

answers:

2

We have the following situation:

  1. We invoke a url which runs an action in a controller. The action is fairly long running - it builds a big string of XML, generates a PDF and is supposed to redirect when done.

  2. After 60 seconds or so, the browswer gets a 200, but with content type of "application/x-unknown-content-type" no body and no Response Headers (using Tamper to look at headers)

  3. The controller action actually continues to run to completion, producing the PDF

This is happening in our prod environment, in staging the controller action runs to completion, redirecting as expected.

Any suggestions where to look?

We're running Rails 2.2.2 on Apache/Phusion Passenger.

Thanks,

+1  A: 

I am not 100% sure, but probably your Apache times out the request to Rails application. Could you try to set Apache's Timeout directive higher? Something like:

Timeout 120
Oleg Shaldybin
+1  A: 

I'd consider bumping this task off to a job queue and returning immediately rather than leaving the user to sit and wait. Otherwise you're heading for a world of problems when lots of people try to use this and you run out of available rails app instances to handle any new connections.

One way to do this easily might be to use an Ajax post to trigger creating the document, drop this into Delayed Job and then run a 10 second periodic check via ajax informing the waiting user of the jobs status. Once delayed_job has finished processing your task in the background and updated something in the database to indicate it is complete, then you can redirect the user via ajax to the newly created document.

davidsmalley