I am trying to use ruby rest-client to upload a large number of images to a site that I'm writing. My code looks like:
RestClient.post url, :timeout => 90000000, :open_timeout => 90000000, :file_param => file_obj
However, I am getting this error:
RestClient::RequestTimeout: Request Timeout
from /Library/Ruby/Gems/1.8/gems/rest-client-1.6.1/lib/restclient/request.rb:174:in `transmit'
from /Library/Ruby/
But when I look at the server log
Completed in 61493ms (View: 2, DB: 1) | 201 Created
So there doesn't appear to be any reason why this is timing out. Anyone have any idea if there is a timeout param I am not correctly setting?
Thanks
This syntax sets the timeout as request header (see RestClient.post signature), if you want to use the timeout parameter you must use:
RestClient::Request.execute(:method => :post, :url => @url, :timeout => 90000000)
see: https://github.com/rest-client/rest-client/blob/master/lib/restclient/request.rb#L12
Looking at the docs, you can pass -1 through RestClient.execute timeout param:
# * :timeout and :open_timeout passing in -1 will disable the timeout by setting the corresponding net timeout values to nil
It can be used as follows:
resource = RestClient::Resource.new(
"url",
:timeout => -1,
:open_timeout => -1
response = resource.get :params => {<params>}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With