How to increase Heroku 30s h12 timeout

heroku, ruby-on-rails, timeout

Solution

I've ended using delayed job + workless, and now my worker dynos only run when they need to.

As heroku has the free 750 hours free per app plan, when you have low usage, you might be able to keep using it for free.

Problem

I'm running a rails app, which has a json webservice call from a local client developed in c++ (a post command with a multipart json form, uploading a streamed file) I already read on Heroku docs about routing mesh, mentioning the 30s Heroku limit for http connections, and about the long polling alternative, referring to worker dynos. During my call I process pdf documents and insert a signature into them. This pdf documents can either be 100kb or 11Mb (or perhaps more). I understand that I'll eventually have to do this action on a background process, but I would like to avoid doing it before I absolutely have to. Do you know of any way of increasing this timeout? As you may see in my code below, I am processing my document after it gets saved (I was doing this inside an `after_save`, but changed to the controller hoping to send the response before processing). I would so expect that the client would get a response before the document processing, but I'm still having a timeout on the heroku side, and an error on my client side. This all works fine with smaller documents, but for a 121 pages pdf document with only 400kb, it blows off.. In the end, my file gets uploaded, so all I need is for that response to proceed to my client app before the timeout response is sent... Any suggestions? my error: ``` at=error code=H12 desc="Request timeout" method=POST path=/documents host=fierce-beach-2720.herokuapp.com fwd="81.193.155.217/bl4-155-217.dsl.telepac.pt" dyno=web.1 queue=0ms wait=0ms connect=1ms service=32272ms status=503 bytes=0 ``` my controller : ``` respond_to do |format| if @document.save! format.html { redirect_to root_path, :flash => { :success => 'Document was successfully created.'} } format.json { render json: @document, status: :created, location: @document} @document.document_process ```

Original source