Connecting via a proxy

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 | wc -l )
45

In fact, if I unset http_proxy, elinks doesn't work:

$ ( unset http_proxy ; elinks -dump 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

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.

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

Ed

···

On Dec 19, 2007 2:56 PM, Robert Citek <robert.citek@gmail.com> wrote:

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 | wc -l )
45

In fact, if I unset http_proxy, elinks doesn't work:

$ ( unset http_proxy ; elinks -dump 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

--
Ed Howland

"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."

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

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 | 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|
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

···

On Dec 20, 2007 6:22 PM, Daniel Sheppard <daniels@pronto.com.au> 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.

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

···

On Dec 26, 2007 5:54 PM, Ed Howland <ed.howland@gmail.com> wrote:

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

I was more interested in the API docs.

What is the main site?

Ed

···

On Dec 27, 2007 9:57 PM, Robert Citek <robert.citek@gmail.com> wrote:

On Dec 26, 2007 5:54 PM, Ed Howland <ed.howland@gmail.com> 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

--
Ed Howland

"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."

The main site is here:

http://bioruby.org/

The API docs are here:

http://bioruby.org/rdoc/

Regards,
- Robert

···

On Jan 2, 2008 5:48 PM, Ed Howland <ed.howland@gmail.com> wrote:

I was more interested in the API docs.

What is the main site?