Last active
May 18, 2016 17:50
-
-
Save jkeck/a973a12d2ea8b2bc4f85e067c9fb4724 to your computer and use it in GitHub Desktop.
Faraday Timeout Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
conn = Faraday.new(url: 'http://localhost:3000') do |faraday| | |
faraday.request :url_encoded | |
faraday.response :logger | |
faraday.adapter Faraday.default_adapter | |
faraday.request :multipart | |
end | |
conn.post do |req| | |
req.url '/test_timout' | |
req.options.timeout = 20 | |
req.options.open_timeout = 20 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestRailsController | |
# post 'test_timeout' => 'test_rails_controller#test_timeout' | |
def test_timeout | |
sleep(25) # This raises Faraday::TimeoutError. sleep(19) will get to the response below | |
render text: 'Got response' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment