Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `socks_proxy' for Net::HTTP:Class (NoMethodError) #53

Open
da2x opened this issue Sep 1, 2022 · 5 comments
Open

undefined method `socks_proxy' for Net::HTTP:Class (NoMethodError) #53

da2x opened this issue Sep 1, 2022 · 5 comments

Comments

@da2x
Copy link

da2x commented Sep 1, 2022

irb(main):001:0> require 'socksify/http'
=> true
irb(main):003:0> Net::HTTP.socks_proxy('127.0.0.1', 9050)
(irb):3:in `<main>': undefined method `socks_proxy' for Net::HTTP:Class (NoMethodError)
Did you mean?  SOCKSProxy                                                            
        from /usr/share/gems/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'         
        from /usr/bin/irb:25:in `load'                                               
        from /usr/bin/irb:25:in `<main>'

ruby 3.1.2p20
socksify 1.7.1

@kornate
Copy link

kornate commented May 3, 2023

Hi @da2x, it seems like you're trying to use the socks_proxy method with the Net::HTTP class, but it's not defined in the socksify gem. Instead, you should use the Socksify::HTTP class, which inherits from Net::HTTP and includes the socks_proxy method. Here's the corrected code:

require 'socksify/http'

# Use Socksify::HTTP instead of Net::HTTP
Socksify::HTTP.socks_proxy('127.0.0.1', 9050)

By using the Socksify::HTTP class instead, you can now properly call the socks_proxy method without encountering the NoMethodError.

@MatzFan
Copy link
Collaborator

MatzFan commented May 7, 2023

@da2x, does @kornate's answer resolve your issue?

@metaskills
Copy link

I followed the README and got the same error. Still getting it with the suggested fix.

> irb
>> require 'socksify/http'
=> true
>> Socksify::HTTP
(irb):2:in `<main>': uninitialized constant Socksify::HTTP (NameError)
	from /Users/kencollins/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/irb-1.6.4/exe/irb:9:in `<top (required)>'
	from /Users/kencollins/.rbenv/versions/3.2.1/bin/irb:25:in `load'
	from /Users/kencollins/.rbenv/versions/3.2.1/bin/irb:25:in `<main>'

@metaskills
Copy link

I see the issue... I'm not sure how this gem is being published, but the code looks nothing like the what is in the v1.7.1 GitHub tag. Lots of things are concatenated in a single lib/socksify.rb and there are only two files in lib... http.rb and debug.rb.

@metaskills
Copy link

I can confirm that after changing my Gemfile to this, the code in the README works.

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'socksify', github: 'astro/socksify-ruby', ref: 'v1.7.2'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants