astro / socksify-ruby

Redirect any TCP connection initiated by a Ruby script through a SOCKS5 proxy
http://socksify.rubyforge.org/
Other
163 stars 77 forks source link

Server doesn't reply (SOCKSError), although curl works #27

Closed joshweir closed 7 years ago

joshweir commented 8 years ago

I have a socks proxy verified by this command:

curl -x socks5://<socks_ip>:<socks_port> "http://canihazip.com/"

When I try to attempt the same thing using ruby socksify gem as per the documentation:

require 'socksify/http'
proxy = '<socks_ip>'
port = '<socks_port>'
uri = URI.parse('http://canihazip.com/')
Net::HTTP.SOCKSProxy(proxy, port).start(uri.host, uri.port) do |http|
  http.get(uri.path)
end

gives error:

/home/resrev/.rvm/gems/ruby-2.2.2/gems/socksify-1.7.0/lib/socksify.rb:269:in `socks_receive_reply':     Server doesn't reply (SOCKSError)
from /home/resrev/.rvm/gems/ruby-2.2.2/gems/socksify-1.7.0/lib/socksify.rb:259:in `socks_connect'
from /home/resrev/.rvm/gems/ruby-2.2.2/gems/socksify-1.7.0/lib/socksify.rb:174:in `initialize'
from /home/resrev/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:879:in `open'
from /home/resrev/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:879:in `block in connect'
from /home/resrev/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/timeout.rb:74:in `timeout'
from /home/resrev/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:878:in `connect'
from /home/resrev/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
from /home/resrev/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:852:in `start'
from /home/resrev/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:583:in `start'
from /home/resrev/pubrevit/lib/tasks/test_rest_client_socks_proxy.rb:51:in `<main>'

What am I missing?

$ ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [i686-linux]
$ rails --version
Rails 4.2.1