# openURI not capturing pages from the same rails app

**URL:** <https://www.ruby-forum.com/t/openuri-not-capturing-pages-from-the-same-rails-app/104203>\
**Category:** Rails\
**Created:** [May 15, 2007, 11:53am UTC](https://www.ruby-forum.com/t/openuri-not-capturing-pages-from-the-same-rails-app/104203 "2007-05-15T11:53:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@tom](https://www.ruby-forum.com/u/tom)\
**Post date:** [May 15, 2007, 11:53am UTC](https://www.ruby-forum.com/t/openuri-not-capturing-pages-from-the-same-rails-app/104203/1 "2007-05-15T11:53:54Z")

</div>

Hi,

I am using standard Ruby library openURI to capture the HTML code from  
other pages. The problem openURI does not work for capturing pages from  
the same rails application.

Here is the code:

class CdCreatorController \< ApplicationController  
require ‘open-uri’

def generate

```
lines = []

file = open("http://127.0.0.1:3001/cd_creator/product/1"){ |f|

```

f.each\_line {|line| lines \<\< line}}

```
@obj = lines

```

end

def product  
@product = Product.find(params[:id]) {|f| f.each\_line {|line| p  
line} }

end  
end

When I call method generate I get an TimeOut Error (execution expired).  
But this method works just fine when I’m capturing pages from Internet  
or local pages  
with different port number.

Please help me.

---

<div class="post-metadata">

**Author:** ![tom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@tom](https://www.ruby-forum.com/u/tom)\
**Post date:** [May 15, 2007, 12:14pm UTC](https://www.ruby-forum.com/t/openuri-not-capturing-pages-from-the-same-rails-app/104203/2 "2007-05-15T12:14:47Z")

</div>

i believe (someone correct me if i am wrong please) the answer is that  
rails only handles one request at a time. what this means is that  
your app is waiting for the current (external) request to finish in  
order to handle the next (internal) request from your open() call.

can i ask why you need to access your app this particular way?

---

<div class="post-metadata">

**Author:** ![tom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@tom](https://www.ruby-forum.com/u/tom)\
**Post date:** [May 15, 2007, 4:48pm UTC](https://www.ruby-forum.com/t/openuri-not-capturing-pages-from-the-same-rails-app/104203/3 "2007-05-15T16:48:15Z")

</div>

I know it sounds crazy, but could it be a DNS issue? Can your  
webserver actually see itself? I ask this because I recently dealt  
with a similar situation (not using rails, but [ASP.NET](http://ASP.NET)) where the  
webserver has some screwy DNS issues where internal calls to 127.0.0.1  
or localhost weren’t routing properly. Even doing a ping to 127.0.0.1  
from commandline wouldn’t work.
