# Connecting via a proxy

**URL:** <https://www.ruby-forum.com/t/connecting-via-a-proxy/123707>\
**Category:** Ruby\
**Created:** [December 19, 2007, 9:56pm UTC](https://www.ruby-forum.com/t/connecting-via-a-proxy/123707 "2007-12-19T21:56:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cluettr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cluettr](https://www.ruby-forum.com/u/cluettr)\
**Post date:** [December 19, 2007, 9:56pm UTC](https://www.ruby-forum.com/t/connecting-via-a-proxy/123707/1 "2007-12-19T21:56:38Z")

</div>

Hello all,

Two questions:

1. in the example below, is our corporate firewall the reason I for the  
error?
2. if so, how can I configure ruby to use the firewall specified in  
http\_proxy?

Details:

I’m trying to connect to an outside http resource but I suspect our  
corporate firewall is blocking the normal route:

$ ruby -rbio -e ‘reg = Bio::Registry.new’  
/usr/lib/ruby/1.8/net/http.rb:560:in `initialize': No route to host - connect(2) (Errno::EHOSTUNREACH) from /usr/lib/ruby/1.8/net/http.rb:560:in `open’  
from /usr/lib/ruby/1.8/net/http.rb:560:in `connect' from /usr/lib/ruby/1.8/timeout.rb:48:in `timeout’  
from /usr/lib/ruby/1.8/timeout.rb:76:in `timeout' from /usr/lib/ruby/1.8/net/http.rb:560:in `connect’  
from /usr/lib/ruby/1.8/net/http.rb:553:in `do_start' from /usr/lib/ruby/1.8/net/http.rb:542:in `start’  
from /usr/lib/ruby/1.8/net/http.rb:440:in `start' from /usr/lib/ruby/1.8/bio/io/registry.rb:190:in `read\_remote’  
from /usr/lib/ruby/1.8/bio/io/registry.rb:126:in `initialize' from -e:1:in `new’  
from -e:1  
$ ruby -v  
ruby 1.8.6 (2007-06-07 patchlevel 36) [i486-linux]

$ lsb\_release -a  
No LSB modules are available.  
Distributor ID: Ubuntu  
Description: Ubuntu 7.10  
Release: 7.10  
Codename: gutsy

The environment variable http\_proxy is configured:

$ env | grep -c http\_proxy  
1

and works for elinks:

$ ( elinks -dump [google.com](http://google.com) | wc -l )  
45

In fact, if I unset http\_proxy, elinks doesn’t work:

$ ( unset http\_proxy ; elinks -dump [google.com](http://google.com) | wc -l )  
ELinks: No route to host  
0

Any pointers in the right direction greatly appreciated. Suggestions  
for a more simple test also appreciated.

Regards,

- Robert

---

<div class="post-metadata">

**Author:** ![cluettr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cluettr](https://www.ruby-forum.com/u/cluettr)\
**Post date:** [December 21, 2007, 1:24am UTC](https://www.ruby-forum.com/t/connecting-via-a-proxy/123707/2 "2007-12-21T01:24:01Z")

</div>

> 1. in the example below, is our corporate firewall the reason  
> I for the error?
> 2. if so, how can I configure ruby to use the firewall  
> specified in http\_proxy?

1. Probably
2. Look at the documentation for the Net::HTTP library - there’s a proxy  
example there.

Dan.

---

<div class="post-metadata">

**Author:** ![cluettr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cluettr](https://www.ruby-forum.com/u/cluettr)\
**Post date:** [December 21, 2007, 4:53am UTC](https://www.ruby-forum.com/t/connecting-via-a-proxy/123707/3 "2007-12-21T04:53:22Z")

</div>

On Dec 20, 2007 6:22 PM, Daniel S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 1. in the example below, is our corporate firewall the reason  
> > I for the error?
> > 2. if so, how can I configure ruby to use the firewall  
> > specified in http\_proxy?
> 
> 1. Probably
> 2. Look at the documentation for the Net::HTTP library - there’s a proxy  
> example there.

Thanks for the hints. Specifically, this is the link I looked at:

[http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html](http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html)

To demonstrate that I can get the proxy to work, I picked google as a  
simple example. Here’s what I can do with  
elinks and with the http\_proxy environment variable set:

$ elinks -source [http://www.google.com](http://www.google.com) | wc  
2 173 5212

With ruby this code works:

$ ruby -r’net/http’ -e ’  
proxy\_addr = “www-gw32” ;  
proxy\_port = 3128 ;  
res=Net::HTTP::Proxy(proxy\_addr, proxy\_port).start(“[www.google.com](http://www.google.com)”)  
{|http|  
http.get(“/”);  
}  
puts res.body ;  
’ | wc  
3 173 5213

While I understand that example (mostly), I don’t understand how to  
wrap that around my existing code. Outside of the proxy, this works  
just fine:

ruby -rbio -e ‘reg = Bio::Registry.new’

When I’m behind the proxy, how can I tell Bio::Registry to use the  
proxy connection?

Regards,

- Robert

---

<div class="post-metadata">

**Author:** ![cluettr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cluettr](https://www.ruby-forum.com/u/cluettr)\
**Post date:** [December 27, 2007, 1:55am UTC](https://www.ruby-forum.com/t/connecting-via-a-proxy/123707/4 "2007-12-27T01:55:55Z")

</div>

Can you give me a pointer to Bio::Registry?

Ed

On Dec 19, 2007 2:56 PM, Robert C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> corporate firewall is blocking the normal route:  
> from /usr/lib/ruby/1.8/net/http.rb:542:in `start’  
> Distributor ID: Ubuntu
> 
> for a more simple test also appreciated.
> 
> Regards,
> 
> - Robert

–  
Ed Howland

> **[Green Programming](http://greenprogrammer.blogspot.com)**
>
> Environmentally safe code

“The information transmitted is intended only for the person or entity  
to which it is addressed and may contain proprietary, confidential  
and/or legally privileged material. Any review, retransmission,  
dissemination or other use of, or taking of any action in reliance  
upon, this information by persons or entities other than the intended  
recipient is prohibited. If you received this in error, please contact  
the sender and delete the material from all computers.”

---

<div class="post-metadata">

**Author:** ![cluettr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cluettr](https://www.ruby-forum.com/u/cluettr)\
**Post date:** [December 28, 2007, 4:58am UTC](https://www.ruby-forum.com/t/connecting-via-a-proxy/123707/5 "2007-12-28T04:58:36Z")

</div>

On Dec 26, 2007 5:54 PM, Ed Howland [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Can you give me a pointer to Bio::Registry?

You can install bioruby like so on Ubuntu Feisty and Gutsy:

$ sudo apt-get install libbio-ruby ruby

You can test if it works with this bit of code:

$ ruby -rbio -le ‘seq = Bio::Sequence::NA.new(“atgcatgcaaaa”) ; print  
seq’

Is that what you were asking?

Regards,

- Robert

---

<div class="post-metadata">

**Author:** ![cluettr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cluettr](https://www.ruby-forum.com/u/cluettr)\
**Post date:** [January 3, 2008, 4:07pm UTC](https://www.ruby-forum.com/t/connecting-via-a-proxy/123707/6 "2008-01-03T16:07:49Z")

</div>

On Jan 2, 2008 5:48 PM, Ed Howland [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I was more interested in the API docs.
> 
> What is the main site?

The main site is here:

[http://bioruby.org/](http://bioruby.org/)

The API docs are here:

[http://bioruby.org/rdoc/](http://bioruby.org/rdoc/)

Regards,

- Robert

---

<div class="post-metadata">

**Author:** ![cluettr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7c8e57/32.png) [@cluettr](https://www.ruby-forum.com/u/cluettr)\
**Post date:** [January 3, 2008, 12:49am UTC](https://www.ruby-forum.com/t/connecting-via-a-proxy/123707/7 "2008-01-03T00:49:11Z")

</div>

I was more interested in the API docs.

What is the main site?

Ed

On Dec 27, 2007 9:57 PM, Robert C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is that what you were asking?
> 
> Regards,
> 
> - Robert

–  
Ed Howland

> **[Green Programming](http://greenprogrammer.blogspot.com)**
>
> Environmentally safe code

“The information transmitted is intended only for the person or entity  
to which it is addressed and may contain proprietary, confidential  
and/or legally privileged material. Any review, retransmission,  
dissemination or other use of, or taking of any action in reliance  
upon, this information by persons or entities other than the intended  
recipient is prohibited. If you received this in error, please contact  
the sender and delete the material from all computers.”
