我正在尝试使用ruby rest-client将大量图片上传到我正在编写的网站。我的代码看起来像这样:
RestClient.post url, :timeout => 90000000, :open_timeout => 90000000, :file_param => file_obj然而,我得到了这个错误:
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/但当我查看服务器日志时
Completed in 61493ms (View: 2, DB: 1) | 201 Created 因此,似乎没有任何原因导致此操作超时。谁知道有没有我没有正确设置的超时参数?
谢谢
发布于 2011-03-27 05:23:41
此语法将超时设置为请求头(请参阅RestClient.post签名),如果要使用超时参数,则必须使用:
RestClient::Request.execute(:method => :post, :url => @url, :timeout => 90000000)请参阅:https://github.com/rest-client/rest-client/blob/master/lib/restclient/request.rb#L12
发布于 2012-07-26 05:07:57
查看文件,可以通过-1 \f25 RestClient.execute timeout -1\f6参数传递:
# * :timeout and :open_timeout passing in -1 will disable the timeout by setting the corresponding net timeout values to nil它的使用方法如下:
resource = RestClient::Resource.new(
"url",
:timeout => -1,
:open_timeout => -1
response = resource.get :params => {<params>}发布于 2012-03-03 10:40:27
我使用了下面的代码,就像Richard指出的那样。
resource = RestClient::Resource.new "url",
:timeout => $TIMEOUT,
:open_timeout => $OPEN_TIMEOUT
response = resource.get :params => { ..... }https://stackoverflow.com/questions/4435538
复制相似问题