我使用的API在开发方面工作正常,但是当我从生产或Heroku Run Rails Console中调用它时,超时。
我正在做以下
url = "http://theapi.example.com"
response = RestClient.get url
在当地我得到200个回应,以骄傲我得到以下内容:
restclient ::异常 从 /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
从 /app/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:145:iinexecute' from /app/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.1/lib/restclient/request.rb:52:in
执行' /app/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.1/lib/restclient.rb:67:iinget' from (irb):30 from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in
开始' /App/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in instart' from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in
console'来自 /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:inrun_command!' from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in
'来自脚本/铁路:6:在require' from script/rails:6:in
'
API不支持SSL,不确定它与它有任何关系。
API提供商将Heroku的IP阻塞以避免攻击。他解除了请求的IP,一切都起作用。