Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Broken ssl module: TypeError: __init__() got an unexpected keyword argument 'server_hostname' #120

Closed
Glandos opened this issue Nov 1, 2014 · 11 comments
Labels

Comments

@Glandos
Copy link

Glandos commented Nov 1, 2014

This is a continuation of what I am experiencing in #92 .

Here is the complete stacktrace, for reference:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "/var/www/search.example.com/searx/venv/local/lib/python2.7/site-packages/grequests.py", line 71, in send
    self.url, **merged_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 456, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 559, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 327, in send
    timeout=timeout
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 304, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 724, in _validate_conn
    conn.connect()
  File "/usr/lib/python2.7/dist-packages/urllib3/connection.py", line 237, in connect
    ssl_version=resolved_ssl_version)
  File "/usr/lib/python2.7/dist-packages/urllib3/util/ssl_.py", line 123, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python2.7/ssl.py", line 350, in wrap_socket
    _context=self)
TypeError: __init__() got an unexpected keyword argument 'server_hostname'
<Greenlet at 0xb65269dcL: <bound method AsyncRequest.send of <grequests.AsyncRequest object at 0xb64e508c>>(stream=False)> failed with TypeError

I am using a virtualenv on an up-to-date Debian/testing (jessie).

It seems that grequests redefined an ssl module, that want to have the same API as Python 2.7. Unfortunately, they introduced server_hostname and other niceties in Python 2.7.9 that seem to have been backported in Debian. And the wrapper is now broken.
Maybe I'm missing something, somewhere… But now, I am unable to have results for all HTTPS sites. This is quite annoying 😄

@asciimoo
Copy link
Member

asciimoo commented Nov 4, 2014

It's because Urllib3/gevent became incompatible with the latest python2.7.8 version. There is an open urllib3 issue about it: urllib3/urllib3#482 .

@asciimoo asciimoo added the bug label Nov 4, 2014
@Glandos
Copy link
Author

Glandos commented Nov 4, 2014

OK, that confirms my debugging session. But now, I have to sit and wait, cause I have no time to change something in a library I know nothing about…

@Cqoicebordel
Copy link
Contributor

I have the same issue.
Is there a way to circumvent it ? Because in the meantime, we can't use searx...

@asciimoo
Copy link
Member

asciimoo commented Dec 5, 2014

Downgrading python to the previous (<=2.7.7) version solves the problem

@asciimoo
Copy link
Member

asciimoo commented Dec 5, 2014

fixed: d959cb1

@Cqoicebordel
Copy link
Contributor

Confirmé.
(Youhou !!!)

@asciimoo asciimoo closed this as completed Dec 6, 2014
@Glandos
Copy link
Author

Glandos commented Dec 6, 2014

Woohooo! Partytime, I can use my own Searx again!
Thanks a lot for the (not so obvious) fix.

@shea256
Copy link

shea256 commented Dec 28, 2014

I had this same problem.

I was using gunicorn and moving away from gevent workers was the fix I went with.

@amitt001
Copy link

I think this problem still persists at least with python 2.7.9(atleast, on heroku).
A workaround is to degrade to python version 2.7.8 or lower.

@avelino
Copy link

avelino commented Apr 12, 2015

Is expected when resolves in Python version 2.7.9?

@FuqiangZhu
Copy link

I'm sorry.

MarcAbonce pushed a commit to MarcAbonce/searx that referenced this issue Jul 16, 2021
…_units.py

Update searx.data - update_wikidata_units.py
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants