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

Already on GitHub? Sign in to your account

Strange EOFError on ruby-2.0.0-preview1 #34

Closed
postmodern opened this Issue Nov 2, 2012 · 7 comments

Comments

Projects
None yet
3 participants

While running the specs for gscraper I got the following error repeatedly under Ruby 2.0.0-preview1:

  29) GScraper::Search::AJAXQuery queries from AJAX search URLs should have a query
     Net::HTTP::Persistent::Error:
       too many connection resets (due to Content-Length (1506) does not match response body length (5306) - EOFError) after 0 requests on 69848766768600, last used 1351826201.368255 seconds ago

I have the same issue while trying to get some url with mechanize.
Mechanize 2.5.1
Net-Http-Persistent 2.8
Ruby 2.0.0-dev (today's tree)

Owner

drbrain commented Feb 9, 2013

Do you have a simple, easy to reproduce example?

Using mechanize 2.5.1 and net-http-persistent 2.8 on ruby 2.0.0-rc2:

require 'mechanize'

agent = Mechanize.new
p agent.get('http://example.com/')

/home/hal/.gem/ruby/2.0.0/gems/net-http-persistent-2.8/lib/net/http/persistent.rb:959:in `rescue in request': too many connection resets (due to Content-Length (606) does not match response body length (1111) - EOFError) after 0 requests on 70321166174580, last used 1360376030.637872 seconds ago (Net::HTTP::Persistent::Error)
from /home/hal/.gem/ruby/2.0.0/gems/net-http-persistent-2.8/lib/net/http/persistent.rb:968:in `request'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:258:in `fetch'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:949:in `response_redirect'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:299:in `fetch'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:949:in `response_redirect'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:299:in `fetch'
from /home/hal/.gem/ruby/2.0.0/gems/mechanize-2.5.1/lib/mechanize.rb:407:in `get'
from mechanize_test.rb:6:in `block in <main>'
from mechanize_test.rb:5:in `times'
from mechanize_test.rb:5:in `<main>'

Actually the 100.times isn't even necessary, fails on the first call.

@drbrain drbrain added a commit that referenced this issue Feb 9, 2013

@drbrain drbrain Only retry exceptions ruby 2 does not handle
Ruby 2 retries requests for some exceptions automatically per RFC 2616.

net-http-persistent must not retry requests that were already retried.

This change rescues exceptions retried by Net::HTTP and does not retry
those exceptions to keep net-http-persistent compliant with RFC 2616.

Related to #34
dc202b2
Owner

drbrain commented Feb 9, 2013

This error is due to Ruby 2 handling content-encoding automatically under the covers, but not informing the user. The bug is actually in mechanize, but I'll leave this open.

Owner

drbrain commented Feb 12, 2013

Filed https://bugs.ruby-lang.org/issues/7831 with a patch, closing this.

@drbrain drbrain closed this Feb 12, 2013

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment