0

I have a proxy set up and running completely fine on my local host. I can connect to the proxy completely fine running this code.

Net::HTTP::Proxy('http://localhost', 1234).start  #do whatever I want after this point

I can connect to it through a browser completely fine, however when I go to run it on mechanize it completely fails. Here's the code.

require 'mechanize'
agent=Mechanize.new
agent.set_proxy('localhost', 1234)
agent.get('http://google.com')   #or any website for that matter

Here's the error I get back

Net::HTTP::Persistent::Error: too many connection resets (due to end of file reached - EOFError) after 0 requests on 22249020, last used 1376802493.5352573 seconds ago

I've read that the versions after 1.0.0 have difficulties connecting to http proxies, but I need to and I'm currently running version 2.7.2. Is there anything I can do to connect to a proxy.

2

2 Answers 2

2

Some proxies can't handle persistent connections (keep-alive). You need to make sure to use a HTTP/1.1-aware proxy.

Sign up to request clarification or add additional context in comments.

Comments

0

What version of Ruby are you running? I have this issue with Ruby 2.1.5 and Mechanize, but not with Ruby 1.9.3.

Presumably you've resolved your problem, but for anyone else who might end up here, downgrading to Ruby 1.9.3 might be a workaround.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.