sparklemotion / mechanize

Mechanize is a ruby library that makes automated web interaction easy.
https://www.rubydoc.info/gems/mechanize/
MIT License
4.39k stars 473 forks source link

ssl.SSLError: [SSL: KRB5_S_TKT_NYV] unexpected eof while reading (_ssl.c:2607) #552

Closed ZephireNZ closed 3 years ago

ZephireNZ commented 4 years ago

Getting the below error when trying to make calls to a mechanize browser instance.

Using mechanize v0.4.3

Traceback (most recent call last):
  File "./asb-import.py", line 210, in <module>
    main()
  File "./asb-import.py", line 206, in main
    process_account(account)
  File "./asb-import.py", line 177, in process_account
    session_id = asb_auth(br, account.asb_username, account.asb_password)
  File "./asb-import.py", line 25, in asb_auth
    br.select_form(name="login")
  File "/usr/lib/python3.8/site-packages/mechanize/_mechanize.py", line 620, in select_form
    global_form = self._factory.global_form
  File "/usr/lib/python3.8/site-packages/mechanize/_html.py", line 313, in global_form
    self.forms()
  File "/usr/lib/python3.8/site-packages/mechanize/_html.py", line 320, in forms
    self._current_forms, self._current_global_form = self._get_forms()
  File "/usr/lib/python3.8/site-packages/mechanize/_html.py", line 335, in _get_forms
    if self.root is None:
  File "/usr/lib/python3.8/site-packages/mechanize/_html.py", line 289, in root
    raw = self._response.read() if self._response else b''
  File "/usr/lib/python3.8/site-packages/mechanize/_response.py", line 199, in read
    self.__cache.write(self.wrapped.read())
  File "/usr/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.8/http/client.py", line 498, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.8/socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.8/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.8/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
ssl.SSLError: [SSL: KRB5_S_TKT_NYV] unexpected eof while reading (_ssl.c:2607)

Below causes the issue:

br = mechanize.Browser()
br.set_handle_robots(False)
br.open('https://online.asb.co.nz/auth/')
br.select_form(name="login") # Error occurs here, also happens with br.title() etc as well
jacobtomlinson commented 4 years ago

Try downgrading openssl to 1.1.1d.

We are also having this issue in our project and I am currently investigating.

ZephireNZ commented 4 years ago

Thanks, downgrading to 1.1.1d did the trick :) Will stop that package from upgrading for now till the issue is resolved.

flavorjones commented 3 years ago

@ZephireNZ and @jacobtomlinson - sorry you're having problems. Unfortunately this project is the Ruby library named mechanize and not the Python library.