开发者

Heroku App: RestClient::InternalServerError

I have built a web app at myapp.heroku.com where "myapp" is actually the random name generated by heroku. When I hit it with my web browser it works. When I hit it with Ruby Rest-Client (gem rest-client v1.6.3) as follows:

irb(main):024:0> response=RestClient.get "http://myapp.heroku.com"

It craps out with the following:

RestClient::InternalServerError: 500 Internal Server Error
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-    1.6.3/lib/restclient/abstract_response.rb:48:in `return!'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-1.6.3/lib/restclient/request.rb:228:in `process_result'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-1.6.3/lib/restclient/request.rb:176:in `block in transmit'
    from C:/Ruby192/lib/ruby/1.9.1/net/http.rb:627:in `start'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-1.6.3/lib/restclient/request.rb:170:in `transmit'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-1.6.3/lib/restclient/request.rb:64:in `execute'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-1.6.3/lib/restclient/request.rb:33:in `execute'
    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/rest-client-1.6.3/lib/restclient.rb:68:in `get'
    from (irb):24
    from C:/Ruby192/bin/irb:12:in `<main>'

When I use the same client with better known URLs, such as "http://www.google.com", or "http://www.heroku.com", it works fine, the content of the URL downloads,开发者_StackOverflow社区 and everything is good. When I use the same client with a version of the application running at "http://localhost:3000", it works fine too.

Am I missing something in my rest-client client which prevents it from GETting data from an app hosted at heroku.com?

============ EDIT ==== additional info ===========

After sleeping on it, I tried:

irb> require 'net/http'
irb> NET::HTTP.get_print URI.parse "http://myapp.heroku.com"

It worked fine.


There could be a number of reasons here;

If you are using a single dyno, it goes out to make the request but then it comes back to the site but there isn't a dyno available to process the request so it times out.

There can be situations where a server is unable to talk back to itself on it's external address but I don't think this is likely to be the case, more likely a dyno issue perhaps?

John.


I goofed.

Upon checking "heroku logs", I found an exception in my code which caused the 500 error. The exception was because of a type casting difference between the PG database in heroku, and my local SQLite3 database. Once I fixed it, everything went well. I suspect that the 500 error also caused my site to be temporarily unaccessible, which is why the subdomain on which my site is hosted did not return anything.

Moral of the story? rest-client works. Heroku works. Rest-client (IMO) shouldn't throw exceptions for a 500, but just return the HTTP response code and let the app deal with it. However, if I whine more, I'll also have to fork & fix...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜