zombocom/rack-timeout

Timeout not working on heroku

ZeeAzmat opened this issue · 9 comments

I tried increasing timeout, I have app running in production and it's deployed on heroku. I have some requests which takes more than 30 seconds. And those requests are insertion in database. Due to requirements i can't move those insertions to background job. I increased timeout to 60 seconds and later i increased this to 80 seconds and it was working fine. But recently it stopped running no matter what i do it's not letting me increase timeout. This works perfectly fine on development environment but not on production.

I used these options:

Rack::Timeout.timeout = 60  # seconds
Rack::Timeout.wait_timeout = 60
Rack::Timeout.wait_overtime = 60
Rack::Timeout.service_timeout = 60
Rack::Timeout.service_past_wait = true

Initially i was using only timeout option and it used to work fine. But later i tried adding more option hoping any of them will work.

Server Output:
2018-09-17T08:00:32.163182+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/organizations/53/events" host=HOST_NAME request_id=abbd22bf-5298-4480-m027-aa00a52a0587 fwd="103.7.79.236" dyno=web.1 connect=1ms service=30135ms status=503 bytes=0 protocol=https

Any help would be appreciated. Thanks in advance.

I think you may not be getting responses to this because it seems like more a Stack Overflow topic. It appears you are using an initializer. As of the most recent version of this gem, they recommend using environmental variables rather than setting in an initializer. However, if you do need to use an initializer you would use something like:

Rails.application.config.middleware.insert_before Rack::Runtime, Rack::Timeout, service_timeout: 60

I came on here looking for more info regarding the environmental variable settings...because I think mine are not working.

Good luck.

Right, this is more like user support, rather than a bug report. I dont mind helping out, but I've been pretty busy with other things.

The confusion here seems to be that rack-timeout settings do not affect upstream services, like Heroku's 30 second timeout, which is implemented in the upstream router.

My app is timing out at the default 15 seconds...even tho I set RACK_TIMEOUT_SERVICE_TIMEOUT to 28. I also tried a heroku config var for RACK_TIMEOUT_SERVICE_TIMEOUT...which, I think does nothing. Where do we need to set the var RACK_TIMEOUT_SERVICE_TIMEOUT in order for the gem to use it?

ENV vars (heroku config vars are ENV vars) will be picked up automatically per:
https://github.com/heroku/rack-timeout#configuring

Setting a Ruby constant will not have any effect.

Note that this is a new feature in 0.5.x though!

Thanks. I do have a heroku config var set (RACK_TIMEOUT_SERVICE_TIMEOUT: 28). However, my app is timing out at the default 15. I'll do some more homework on this.

@atstockland Did you find any solution? I am having the same problem.

@aruprakshit this was a while back. I’m not sure what solution I used. I’ll take a look and follow up if I have something that may help you.

@atstockland Thanks man. It is such a weird thing, I am now ran out of idea.