简体   繁体   中英

HTTPClient::ConnectTimeoutError while using 'fb_graph' gem

I have one rails project and two machinges. One is running Ubuntu 10.04 and the other 12.04 beta. I'm using the 'fb_graph' gem on the 10.04 machine all works fine, but when I do on the 12.04 machine things like

me = FbGraph::User.me(token).fetch

I get

HTTPClient::ConnectTimeoutError: execution expired
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:300:in `connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:300:in `ssl_connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:739:in `block in connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:731:in `connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:594:in `query'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:161:in `query'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient.rb:1060:in `do_get_block'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient.rb:869:in `block in do_request'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient.rb:956:in `protect_keep_alive_disconnected'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient.rb:868:in `do_request'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient.rb:756:in `request'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/httpclient-2.2.4/lib/httpclient.rb:661:in `get'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:49:in `block in get'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:122:in `handle_response'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:48:in `get'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:18:in `fetch'
from (irb):10
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/railties-3.2.0/lib/rails/commands/console.rb:47:in `start'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/railties-3.2.0/lib/rails/commands/console.rb:8:in `start'
from /home/jan/.rvm/gems/ruby-1.9.2-p290@ece/gems/railties-3.2.0/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

I have no idea why this happen nor how I could solve it. Any ideas? Thanks!

Jan

Reasons it could be happening are hardware performance of the machine, and network performance.

Try it again a couple times. Sometimes the network needs time to load routing information, but once it's loaded it goes faster the next times. That may not be a good production solution, but it could diagnose if the problem is freshening the network routing.

This could be a true network performance issue. That might not help you, if you cannot tune your network.

If re-trying helps, you could put a re-try loop around your code.

(0..2).each do
  begin
    ... #your code goes here
    break
  rescue HTTPClient::ConnectTimeoutError
  end
end

The HTTP request is timing out between the server and FB. See this github issue for an explanation of how to configure the HTTP client's timeout option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM