connecting via a proxy

R

Robert Citek

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
 
D

Daniel Sheppard

1) in the example below, is our corporate firewall the reason=20
I for the error?
2) if so, how can I configure ruby to use the firewall=20
specified in http_proxy?

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

Dan.
 
R

Robert Citek

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

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
 
E

Ed Howland

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

Ed

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
http://greenprogrammer.blogspot.com
"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."
 
R

Robert Citek

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
 
E

Ed Howland

I was more interested in the API docs.

What is the main site?

Ed

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
http://greenprogrammer.blogspot.com
"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."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,112
Latest member
VinayKumar Nevatia
Top