我在 Heroku 托管的 Rails 应用程序中进行了一项操作,该应用程序在后台进程中运行,并调用速度很慢的政府网站。我收到无法修复的超时错误(在下方)。
读取超时出现在请求的 20 秒处。
以下行导致问题:
Mechanize.new.get('http://ai.fmcsa.dot.gov/SMS/Data/Search.aspx')
是否有解决此问题的环境变量?还有什么我想念的吗?
Errno::ETIMEDOUT: Connection timed out - connect(2)
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:29:in `initialize'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:29:in `open'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:29:in `block in connect'
from /usr/local/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
from /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:29:in `connect'
from /usr/local/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
from /usr/local/lib/ruby/1.9.1/net/http.rb:632:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent.rb:768:in `reset'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent.rb:503:in `connection_for'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent.rb:806:in `request'
from /app/vendor/bundle/ruby/1.9.1/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:258:in `fetch'
from /app/vendor/bundle/ruby/1.9.1/gems/mechanize-2.5.1/lib/mechanize.rb:407:in `get'
from /app/app/models/inspection.rb:14:in `fmcsa_summary'
from (irb):5
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'