I'm having trouble getting Proxy to work properly within our corporate
firewall. I've validated the proxy settings. Mozilla is able to reach
the Internet just fine using the specified proxy, but my demo Ruby app
is not.
Also, I noticed that I was not able to reach a site within the firewall
unless I specified the IP address rather than the URL. I've done some
sniffing through the stack using the debugger, and the correct URL
seems to be passed down through it.
Any suggestions as to what configuration settings I should check or
what to watch for in the stack would be welcome.
Here is what I'm running:
require ‘net/http’
h =
Net::HTTP::Proxy(‘http://proxy-sd.am.sony.com/proxy/proxy.pac’,8080)
#h.start(‘http://www.pragmaticprogrammer.com’) do |http| #doesn’t work
h.start(URI.parse(‘http://www.pragmaticprogrammer.com’)) do |http|
response = h.get(’/index.htm’)
if response.message ==“OK”
puts response.body.scan(/<img src="(.*?)"/m).uniq
end
end
[mitchell@localhost tutorials]$ ruby -w t18_HTTP_Network.rb
/usr/local/lib/ruby/1.8/net/protocol.rb:83:in `initialize':
getaddrinfo: Name or service not known (SocketError)
from /usr/local/lib/ruby/1.8/net/protocol.rb:83:in `new'
from /usr/local/lib/ruby/1.8/net/protocol.rb:83:in `connect'
from /usr/local/lib/ruby/1.8/net/protocol.rb:82:in `timeout'
from /usr/local/lib/ruby/1.8/timeout.rb:55:in `timeout'
from /usr/local/lib/ruby/1.8/net/protocol.rb:82:in `connect'
from /usr/local/lib/ruby/1.8/net/protocol.rb:64:in `initialize'
from /usr/local/lib/ruby/1.8/net/http.rb:430:in `open'
from /usr/local/lib/ruby/1.8/net/http.rb:430:in `do_start'
from /usr/local/lib/ruby/1.8/net/http.rb:419:in `start'
from /usr/local/lib/ruby/1.8/net/http.rb:324:in `start'
from t18_HTTP_Network.rb:9