如何在Rails中为Facebook使用koalagem引发超时错误?
如果有人知道,请告诉我。
您可以使用ruby的Timeout模块,如下所示:
require 'timeout'
begin
status = Timeout::timeout(5) do
@koala_api.get_connection 'me', :feed
end
rescue Timeout::Error
# do something on timeout
end
最好的方法是:Koala.http_service.http_options = {request: {open_timeout: 1, timeout: 1}}