Feedtools question

I use feedtools to generate the feeds and read them,and now they can not
work well:
This is the code for feed generating:
class FeedsController < ApplicationController
def userrss
@user = User.find_by_id(params[:id])
@articles = @user.articles(:all,:order => ‘updated_at desc’)
@headers[“Content-Type”] = “application/xml; charset=utf-8”
@feed = FeedTools::Feed.new
@feed.title = “#{@user.login}”
@feed.author = “#{@user.login}”
@feed.link = “http://localhost:3000
@articles.each do|@article|
@feed_item = FeedTools::FeedItem.new
@feed_item.link =
http://localhost:3000/articles/view/#{@article.id}
@feed_item.content = render_to_string(:layout => false, :template
=> “articles/view.rhtml”)
@feed.entries << @feed_item
end
end
end
and
@feed.build_xml(‘rss’, 2.0)
in userrss.rxml
They can generate the rss feeds well,eg,if I type
http://localhost:3000/feeds/userrss/1
I can get well organized xml output.

Following is the code for feeds reading:

@feed =
FeedTools::Feed.open(“http://localhost:3000/feeds/userrss/#{params[:id]}”)

I will get the timeout error if i want to read my feeds:
FeedTools::FeedAccessError (Timeout while attempting to retrieve feed):
d:/ruby/lib/ruby/gems/1.8/gems/feedtools-0.2.24/lib/feed_tools/helpers/retrieval_helper.rb:195:in
http_request' d:/ruby/lib/ruby/gems/1.8/gems/feedtools-0.2.24/lib/feed_tools/helpers/retrieval_helper.rb:220:in http_get’
d:/ruby/lib/ruby/gems/1.8/gems/feedtools-0.2.24/lib/feed_tools/feed.rb:204:in
load_remote_feed!' d:/ruby/lib/ruby/gems/1.8/gems/feedtools-0.2.24/lib/feed_tools/feed.rb:119:in update!’
d:/ruby/lib/ruby/gems/1.8/gems/feedtools-0.2.24/lib/feed_tools/feed.rb:80:in
`open’

but if i use some other feed url on internet,it can work well.

What is the reason that feedtools can not read the feed that feedtools
generate?

Thanks

I trace into the feedtools’ source
And I found that the http connection can not be established.
no matter what address i set except for remote,eg:
http://localhost:3000/users/1
http://localhost:3000,etc, the connection can not be establieshed and
with a return error of connection time out

That is to say the following steps can not work normally under webrick
enviroment?

1 Browser send a http request to controller A and wait for response
2 controller A send a http request to controller B and wait for response
3 Browser will not get the response unless controller A got response
from controller B

Is this the reason of webrick or feedtools?

charlie wrote:

I use feedtools to generate the feeds and read them,and now they can not
work well:
This is the code for feed generating:
class FeedsController < ApplicationController
def userrss
@user = User.find_by_id(params[:id])
@articles = @user.articles(:all,:order => ‘updated_at desc’)
@headers[“Content-Type”] = “application/xml; charset=utf-8”
@feed = FeedTools::Feed.new
@feed.title = “#{@user.login}”
@feed.author = “#{@user.login}”
@feed.link = “http://localhost:3000
@articles.each do|@article|
@feed_item = FeedTools::FeedItem.new
@feed_item.link =
http://localhost:3000/articles/view/#{@article.id}
@feed_item.content = render_to_string(:layout => false, :template
=> “articles/view.rhtml”)
@feed.entries << @feed_item
end
end
end
and
@feed.build_xml(‘rss’, 2.0)
in userrss.rxml
They can generate the rss feeds well,eg,if I type
http://localhost:3000/feeds/userrss/1
I can get well organized xml output.

Following is the code for feeds reading:

@feed =
FeedTools::Feed.open(“http://localhost:3000/feeds/userrss/#{params[:id]}”)

I will get the timeout error if i want to read my feeds:
FeedTools::FeedAccessError (Timeout while attempting to retrieve feed):
d:/ruby/lib/ruby/gems/1.8/gems/feedtools-0.2.24/lib/feed_tools/helpers/retrieval_helper.rb:195:in
http_request' d:/ruby/lib/ruby/gems/1.8/gems/feedtools-0.2.24/lib/feed_tools/helpers/retrieval_helper.rb:220:in http_get’
d:/ruby/lib/ruby/gems/1.8/gems/feedtools-0.2.24/lib/feed_tools/feed.rb:204:in
load_remote_feed!' d:/ruby/lib/ruby/gems/1.8/gems/feedtools-0.2.24/lib/feed_tools/feed.rb:119:in update!’
d:/ruby/lib/ruby/gems/1.8/gems/feedtools-0.2.24/lib/feed_tools/feed.rb:80:in
`open’

but if i use some other feed url on internet,it can work well.

What is the reason that feedtools can not read the feed that feedtools
generate?

This is probably a threading problem. You have one thread on your server
and you are trying to use it to read from the same server. Looking at
the source code it seems like webrick at least only has a single thread.

Do you see the request coming in to get
http://localhost:3000/feeds/userrss/1?

Open http://localhost:3000/feeds/userrss/1 in your browser and save it
to a file and then open that file using FeedTools. Can you read it?

How many threads are on your server?

If your answers were “no,” “yes” and either “1” or “I don’t know,” you
might want to check out setting ActionController::Base.allow_concurrency
in your configuration, or if that doesn’t work, and this option isn’t in
the api docs, so it may not, try running two servers, one on port 3000
and one on port 3001 and see if it works.

Ray

Thanks
I change the value of allow_concurrency from false to true,the
FeedTools::Feed.open() can work then, although other controller actions
may not work,it can help with this controller’s debugging,and after
apache or lighthttpd has been deloyed,all matters will be settled i
think