Date
1 - 3 of 3
Timeouts
Manuel Palenciano <mpalenciano@...>
Begin forwarded message: From: Manuel Palenciano <mpalenciano@...> Date: April 1, 2011 11:01:02 AM GMT+02:00 To: rest.client@... Subject: Timeouts Hello there, I have 2 Rails apps talking each other thru an API using your wonderful RestClient library. Everything works fine, excepting some RestClient::Timeout exceptions, and I wonder if we should be using timeouts, since I do not completely understand them, specially the open_timeout option. I would implement timeouts the following way: mattr_accessor :resource @@resource = RestClient::Resource.new base_url, :timeout => 20, :open_timeout => 20 def self.get(uri, params = nil) resource[uri].get :params => params do |response, request, result| case response.code when 200 ActiveSupport::JSON.decode response else raise "Response status: #{response.code}" end end end I just need to know, please, if this way is RIGHT, and if I should use 'open_timeout' or not, since I have no clue what it does and could not find good documentation about it (even in the HTTP docs) Thanks a lot in advance! Manuel Palenciano |
|
code@...
AFAIK the open timeout is the timeout to open the connection and the timeout (called read_timeout) is when reading an answer. So depending if the timeout is during the initial connection or during the http transfert it may be on or the other, your code sample seems good if it is the initial connection that fails. I hope it helps A. |
|
Manuel Palenciano <mpalenciano@...>
Sure it helped!
We get Timeouts due to some relatively heavy SQL queries we make across both apps, via the API. So I guess, we will be safer using both: timeout and open_timeout; since both apps could do the initial connection (?). Thanks very much for your quick response. Manuel Palenciano On Apr 1, 2011, at 9:05 PM, code@... wrote: Begin forwarded message: From: Manuel Palenciano <mpalenciano@...> Date: April 1, 2011 11:01:02 AM GMT+02:00 To: rest.client@... Subject: Timeouts Hello there, I have 2 Rails apps talking each other thru an API using your wonderful RestClient library. Everything works fine, excepting some RestClient::Timeout exceptions, and I wonder if we should be using timeouts, since I do not completely understand them, specially the open_timeout option. I would implement timeouts the following way: mattr_accessor :resource @@resource = RestClient::Resource.new base_url, :timeout => 20, :open_timeout => 20 def self.get(uri, params = nil) resource[uri].get :params => params do |response, request, result| case response.code when 200 ActiveSupport::JSON.decode response else raise "Response status: #{response.code}" end end end I just need to know, please, if this way is RIGHT, and if I should use 'open_timeout' or not, since I have no clue what it does and could not find good documentation about it (even in the HTTP docs) Thanks a lot in advance! Manuel Palenciano AFAIK the open timeout is the timeout to open the connection and the timeout (called read_timeout) is when reading an answer. So depending if the timeout is during the initial connection or during the http transfert it may be on or the other, your code sample seems good if it is the initial connection that fails. I hope it helps A. |
|