RSS file reading/parsing and Connection timed out – connect(2) [resolved]

This post is about

1. Read Rss feed
2. Time out problem handling
3. Some explaination about RSS reading

def get_leonardo_hotels
   url, timeout =  '', 60
   uri = URI.parse(url)
   http =, uri.port)
   http.open_timeout = timeout 
   http.read_timeout = timeout 
   # http.use_ssl = (uri.scheme == 'https')
   http.request_get(uri.request_uri) do |response|
     data = response.read_body
     data = RSS::Parser.parse(data, false)
     # puts do |item|
        puts "------->"
        puts item.title
        puts "------->"


All in all the above function is used for RSS reading and handling time out problem.

Time out increased by setting http open_timeout and read_timeout to 60 seconds

url, timeout =  '', 60
#code here
http.open_timeout = timeout 
http.read_timeout = timeout 

To read RSS Feed

data = response.read_body
data = RSS::Parser.parse(data, false) do |item|
   puts item.inspect

Time out links

Http open_timeout and read_timeout
Rss feed links

RSS understanding

<rss version=”2.0″>
<![CDATA[ eng ]]>
<![CDATA[ 246 ]]>
<![CDATA[ Leonardo Plaza Hotel Tiberias ]]>
<![CDATA[ – Superior Room 255×130.jpg


1. In above rss there is no <items> tag but it is important to note that you are getting list of them using items.

2. You will also skip node when reading data


I am Senior Software Engineer. I love reading, writing, sharing,developing, hiking, movies, trips, mountains, brooks, hills etc.

Tagged with: , , , , , ,
Posted in RSS

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: