0

I'm doing some simple RSS parsing and rendering - works perfectly fine on localhost and production at Heroku, but for some reason this particular RSS feed works only on localhost, but not when deployed at Heroku.

Here is the RSS feed:

http://careers.joelonsoftware.com/jobs/feed?tags=network

Here is the error I get on Heroku:

A ActionView::Template::Error occurred in jobs#index:
503 Service Unavailable
/usr/local/lib/ruby/1.9.1/open-uri.rb:346:in `open_http'

Here is my code:

@rss = RSS::Parser.parse(the_rss_feed, false)
render :partial => "layouts/rss_syndicated_jobs", :locals => {:rss => @rss}

I'm requiring:

require 'rss/2.0'
require 'open-uri'

This seems to be a perfectly valid RSS feed - and again, works fine on localhost - but not when deployed at Heroku....any thoughts?

cman77
  • 1,753
  • 1
  • 22
  • 48

1 Answers1

1

That domain doesn't like heroku's servers making HTTP GET requests.

From Heroku

➜  deefour ✗ heroku run "curl -s -D - careers.joelonsoftware.com/jobs/feed -o /dev/null"
Running `curl -s -D - careers.joelonsoftware.com/jobs/feed -o /dev/null` attached to terminal... up, run.9211
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html

From Local Machine

➜  deefour ✗ curl -s -D - careers.joelonsoftware.com/jobs/feed -o /dev/null 
HTTP/1.1 200 OK
Cache-Control: private, max-age=1800
Content-Type: application/rss+xml; charset=utf-8
Expires: Tue, 27 Nov 2012 02:46:38 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: x-requested-with
Access-Control-Max-Age: 60
Date: Tue, 27 Nov 2012 02:16:38 GMT
Content-Length: 10982

If you print the response body through Heroku it provides the following info

This IP is only allowed to access our API. To protect our users, we can't process requests from this IP address. If you believe you have reached this page in error, contact us.

deefour
  • 34,974
  • 7
  • 97
  • 90
  • Awesome - God know how much time you just saved me. – cman77 Nov 27 '12 at 03:48
  • Can I ask how you did this "If you print the response body through Heroku it provides the following info" – cman77 Nov 27 '12 at 13:03
  • Yeah, just don't use any of the flags in the curl command. Simply do `heroku run "curl careers.joelonsoftware.com/jobs/feed"`. `heroku run` will run arbitrary shell commands against the heroku instance *(though not everything is supported/allowed/available)* – deefour Nov 27 '12 at 13:04
  • Oddly - i'm seeing the same issue with `http://seeker.dice.com/jobsearch/rss/US/Windows` yet `heroku run "curl http://seeker.dice.com/jobsearch/rss/US/Windows"' works. – cman77 Nov 30 '12 at 16:32
  • Perhaps their detection method is not based on the IP, but some other criteria (ie. the request headers). You might be able to play with the parser's request headers to get dice to work if that's the case. – deefour Nov 30 '12 at 16:40