whalabi
whalabi

Reputation: 101

Set rails request timeout (execution expired)

Should be an easy one but google isn't helping: can't find a way to get rails to wait longer before a request expires

ActionView::Template::Error (execution expired)

=> Booting Thin
=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

Upvotes: 10

Views: 21524

Answers (2)

Patrice Gagnon
Patrice Gagnon

Reputation: 1464

First, gem list to see your rack_timeout version.

If you're using rack_timeout <= 0.4 then use

Rack::Timeout.timeout = 30 # seconds inside the config/initializers/timeout.rb

If you're using rack_timeout >= 0.5 then use the following environment variables.

service_timeout:   15     # RACK_TIMEOUT_SERVICE_TIMEOUT
wait_timeout:      30     # RACK_TIMEOUT_WAIT_TIMEOUT
wait_overtime:     60     # RACK_TIMEOUT_WAIT_OVERTIME
service_past_wait: false  # RACK_TIMEOUT_SERVICE_PAST_WAIT

In rails, you can load environment variables in a .env file:

gem 'dotenv-rails'

In your config/environments/development.rb (or other) do:

Dotenv::Railtie.load

Then, in the root of your rails project, your .env will look like:

RACK_TIMEOUT_SERVICE_TIMEOUT=15
RACK_TIMEOUT_WAIT_TIMEOUT=30
RACK_TIMEOUT_WAIT_OVERTIME=60
RACK_TIMEOUT_SERVICE_PAST_WAIT=false

Upvotes: 6

Thaha kp
Thaha kp

Reputation: 3709

If you are using gem "rack-timeout" Then change the Rack::Timeout.timeout = 30 # seconds or more inside the config/initializers/timeout.rb file. Use this link for more details.

Upvotes: 4

Related Questions