# Feedtools question

**URL:** <https://www.ruby-forum.com/t/feedtools-question/225902>\
**Category:** Rails\
**Created:** [April 29, 2006, 8:47am UTC](https://www.ruby-forum.com/t/feedtools-question/225902 "2006-04-29T08:47:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [April 29, 2006, 8:47am UTC](https://www.ruby-forum.com/t/feedtools-question/225902/1 "2006-04-29T08:47:28Z")

</div>

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](http://localhost:3000)”  
@articles.each do|@article|  
@feed\_item = FeedTools::FeedItem.new  
@feed\_item.link =  
“[http://localhost:3000/articles/view/#{@article.id}](http://localhost:3000/articles/view/#%7B@article.id%7D)”  
@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](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]}](http://localhost:3000/feeds/userrss/#%7Bparams%5B:id%5D%7D)”)

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

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [April 29, 2006, 10:24am UTC](https://www.ruby-forum.com/t/feedtools-question/225902/2 "2006-04-29T10:24:14Z")

</div>

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/users/1)  
[http://localhost:3000](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?

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [April 29, 2006, 10:55am UTC](https://www.ruby-forum.com/t/feedtools-question/225902/3 "2006-04-29T10:55:28Z")

</div>

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](http://localhost:3000)”  
> @articles.each do|@article|  
> @feed\_item = FeedTools::FeedItem.new  
> @feed\_item.link =  
> “[http://localhost:3000/articles/view/#{@article.id}](http://localhost:3000/articles/view/#%7B@article.id%7D)”  
> @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](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]}](http://localhost:3000/feeds/userrss/#%7Bparams%5B:id%5D%7D)”)
> 
> 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](http://localhost:3000/feeds/userrss/1)?

Open [http://localhost:3000/feeds/userrss/1](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

---

<div class="post-metadata">

**Author:** ![charlie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d6d6ee/32.png) [@charlie](https://www.ruby-forum.com/u/charlie)\
**Post date:** [April 29, 2006, 3:23pm UTC](https://www.ruby-forum.com/t/feedtools-question/225902/4 "2006-04-29T15:23:18Z")

</div>

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
