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

conn: Catch ssl.EOFErrors on Python3.3 so we close the failing conn #1162

Merged
merged 1 commit into from
Aug 1, 2017

Conversation

Ormod
Copy link
Contributor

@Ormod Ormod commented Aug 1, 2017

I saw this traceback as a recurring loop in my client which uses KafkaConsumer:

...
File "/usr/lib/python3.5/site-packages/kafka/client_async.py", line 491, in send
if not self._maybe_connect(node_id):
File "/usr/lib/python3.5/site-packages/kafka/client_async.py", line 368, in _maybe_connect
conn.connect()
File "/usr/lib/python3.5/site-packages/kafka/conn.py", line 355, in connect
if self._try_handshake():
File "/usr/lib/python3.5/site-packages/kafka/conn.py", line 420, in _try_handshake
self._sock.do_handshake()
File "/usr/lib64/python3.5/ssl.py", line 996, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib64/python3.5/ssl.py", line 641, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:720)

Based on: https://docs.python.org/3/library/ssl.html:

exception ssl.SSLEOFError

A subclass of SSLError raised when the SSL connection has been terminated
abruptly. Generally, you shouldn’t try to reuse the underlying transport
when this error is encountered.

So start closing the connection if we get EOFError from the connection
instead of just raising the exception up the stack.

I saw this traceback as a recurring loop in my client which uses KafkaConsumer:

...
File "/usr/lib/python3.5/site-packages/kafka/client_async.py", line 491, in send
  if not self._maybe_connect(node_id):
File "/usr/lib/python3.5/site-packages/kafka/client_async.py", line 368, in _maybe_connect
  conn.connect()
File "/usr/lib/python3.5/site-packages/kafka/conn.py", line 355, in connect
  if self._try_handshake():
File "/usr/lib/python3.5/site-packages/kafka/conn.py", line 420, in _try_handshake
  self._sock.do_handshake()
File "/usr/lib64/python3.5/ssl.py", line 996, in do_handshake
  self._sslobj.do_handshake()
File "/usr/lib64/python3.5/ssl.py", line 641, in do_handshake
  self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:720)

Based on: https://docs.python.org/3/library/ssl.html:

  exception ssl.SSLEOFError

  A subclass of SSLError raised when the SSL connection has been terminated
  abruptly. Generally, you shouldn’t try to reuse the underlying transport
  when this error is encountered.

So start closing the connection if we get EOFError from the connection
instead of just raising the exception up the stack.
@dpkp dpkp merged commit 3ff3d75 into dpkp:master Aug 1, 2017
@dpkp
Copy link
Owner

dpkp commented Aug 1, 2017

Thanks!

@Ormod Ormod deleted the ssl_eof_error branch August 8, 2017 11:23
88manpreet pushed a commit to Yelp/kafka-python that referenced this pull request Aug 25, 2017
88manpreet pushed a commit to Yelp/kafka-python that referenced this pull request Oct 6, 2017
88manpreet pushed a commit to Yelp/kafka-python that referenced this pull request Jul 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants