Вопрос

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?

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top