API 调用开发工作,生产 heroku 超时

API call works on development, timesout on production heroku

我正在使用 API,它在开发中运行良好,但当我从生产或 heroku 运行 rails 控制台调用它时超时。

我正在做以下事情

url = "http://theapi.example.com"
response = RestClient.get url

我在本地收到 200 响应 我得到以下信息:

RestClient::Exceptions::OpenTimeout: Timed out connecting to server from /app/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:731:in rescue in transmit' from /app/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:647:in transmit' from /app/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:145:in execute' from /app/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:52:in execute' from /app/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.1/lib/restclient.rb:67:in get' from (irb):30 from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in start' from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in start' from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in console' from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in run_command!' from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in ' from script/rails:6:in require' from script/rails:6:in'

API不支持ssl,不知道跟这个有什么关系

API 提供商屏蔽了 Heroku 的 IP 以避免受到攻击。他解封了请求的IP,一切正常。