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

requests.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:600) #2616

Closed
kristjanr opened this issue May 28, 2015 · 21 comments

Comments

@kristjanr
Copy link

r = requests.get('https://www.digitist.com', verify=False)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/api.py", line 69, in get
    return request('get', url, params=params, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:600)

I am using Python 3.4 on OSX Yosemite

@Lukasa
Copy link
Member

Lukasa commented May 28, 2015

Python 3.4, OS X Yosemite, Requests 2.7.0: I cannot reproduce this bug. =) Can you consistently hit it? What requests version are you using?

@sigmavirus24
Copy link
Contributor

Also, what version of openssl and do you have pyOpenSSL installed?

@kristjanr
Copy link
Author

requests 2.7.0
OpenSSL 1.0.2 22 Jan 2015
I did not have pyOpenSSL installed.

I installed the latest version of pyOpenSSL 0.15.1 and ran the same request again.
Still the same result.

@sigmavirus24
Copy link
Contributor

Are you behind a proxy?

@kristjanr
Copy link
Author

No, I am not behind a proxy.

@kristjanr
Copy link
Author

I consistently get this problem. By now, I have tried with 3 different networks.

As soon as you are sure that this problem is not relative to requests, we can drop this :) because I only have this problem on my dev machine. Our production environment is Ubuntu and the request to the same url works fine there.

But until then, I am more than happy to give all the information you need for debugging.

@Lukasa
Copy link
Member

Lukasa commented May 29, 2015

The OpenSSL version number you gave us: how did you obtain it?

@kristjanr
Copy link
Author

I typed in "openssl version" in the terminal:

Kristjans-MBP:leech kristjan$ openssl version
OpenSSL 1.0.2 22 Jan 2015

And for the one in Python:

>>> import OpenSSL
>>> OpenSSL.__version__
'0.15.1'

@Lukasa
Copy link
Member

Lukasa commented May 29, 2015

Sorry, can you do

import ssl
print ssl.OPENSSL_VERSION

@kristjanr
Copy link
Author

>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 0.9.8zd 8 Jan 2015'

@Lukasa
Copy link
Member

Lukasa commented May 29, 2015

Awesome, so you're using a very old OpenSSL version. How did you install Python 3?

@kristjanr
Copy link
Author

I used Mac OS X 64-bit/32-bit installer from here https://www.python.org/downloads/release/python-340/

@Lukasa
Copy link
Member

Lukasa commented May 29, 2015

Weird, I thought that bundled a newer OpenSSL. I recommend installing it using Homebrew, which will link against a newer OpenSSL.

@kristjanr
Copy link
Author

What about macports? I use this as my package manager.

On 18:54, Fri, May 29, 2015 Cory Benfield notifications@github.com wrote:

Weird, I thought that bundled a newer OpenSSL. I recommend installing it
using Homebrew http://brew.sh/, which will link against a newer OpenSSL.


Reply to this email directly or view it on GitHub
https://github.com/kennethreitz/requests/issues/2616#issuecomment-106855278
.

@Lukasa
Copy link
Member

Lukasa commented May 29, 2015

I don't know about macports: you'll want to check with them whether they compile against the system OpenSSL or against one they provide.

@Lukasa Lukasa closed this as completed May 31, 2015
@mieciu
Copy link

mieciu commented Jun 8, 2015

If somebody still encounters this issue on their OS X stack I'll strongly recommend reinstalling Python 3 from https://www.python.org/downloads/ rather than homebrew - I've faced exactly the same thing and this was a proper solution for me 😄

@sigmavirus24
Copy link
Contributor

@mieciu thanks for the input. That said, my recommendation is to use homebrew. 😉

@biplab-dholey
Copy link

EOF occurred in violation of protocol (_ssl.c:590) i am getting this error.
do this
import requests
sess = requests.Session()
adapter = requests.adapters.HTTPAdapter(max_retries = 1000)
sess.mount('http://', adapter)

and do sess.post() but still got the same error. could you guys help me it that???

@Lukasa
Copy link
Member

Lukasa commented Sep 22, 2016

@biplab-dholey This error can occur for a number of reasons. The retries count is unrelated. This error results from your TLS configuration, and without more information it's very difficult for us to help.

@flyaway921
Copy link

I hit this error and I finally find I was accessing a none HTTPS service with a HTTPS protocol.

@pkwv2012
Copy link

pkwv2012 commented Nov 30, 2017

SSLEOFError occurred when getting www.google.com using proxies.

default_socket = socket.socket
socks.set_default_proxy(socks.SOCKS5, SOCKS5_PROXY_HOST, SOCKS5_PROXY_PORT)
socket.socket = socks.socksocket
import requests
html_source = requests.get(url, headers={"User-Agent": "Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101"}).text
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 560, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 787, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 252, in connect
    ssl_version=resolved_ssl_version)
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 305, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.5/ssl.py", line 377, in wrap_socket
    _context=self)
  File "/usr/lib/python3.5/ssl.py", line 752, in __init__
    self.do_handshake()
  File "/usr/lib/python3.5/ssl.py", line 988, in do_handshake
    self._sslobj.do_handshake()
  File "/usr/lib/python3.5/ssl.py", line 633, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 589, in urlopen
    raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "request.py", line 19, in <module>
    html_source = requests.get(url, headers={"User-Agent": "Mozilla/5.001 (windows; U; NT4.0; en-US; rv:1.0) Gecko/25250101"}).text
  File "/usr/lib/python3/dist-packages/requests/api.py", line 67, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 447, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:645)

the environment of my computer

Ubuntu 16.04
python3.5.2
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2g  1 Mar 2016'
>>> import requests
>>> requests.__version__
'2.9.1'

BUT, this code works well when getting https://www.facebook.com/

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants