From 3ff3d75004f94fd55fa089297d3e2376e33ccda7 Mon Sep 17 00:00:00 2001 From: Hannu Valtonen Date: Tue, 1 Aug 2017 23:52:41 +0300 Subject: conn: Catch ssl.EOFErrors on Python3.3 so we close the failing conn (#1162) --- kafka/conn.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'kafka') diff --git a/kafka/conn.py b/kafka/conn.py index 16eaf62..6a9c200 100644 --- a/kafka/conn.py +++ b/kafka/conn.py @@ -35,6 +35,7 @@ try: import ssl ssl_available = True try: + SSLEOFError = ssl.SSLEOFError SSLWantReadError = ssl.SSLWantReadError SSLWantWriteError = ssl.SSLWantWriteError SSLZeroReturnError = ssl.SSLZeroReturnError @@ -43,6 +44,7 @@ try: log.warning('Old SSL module detected.' ' SSL error handling may not operate cleanly.' ' Consider upgrading to Python 3.3 or 2.7.9') + SSLEOFError = ssl.SSLError SSLWantReadError = ssl.SSLError SSLWantWriteError = ssl.SSLError SSLZeroReturnError = ssl.SSLError @@ -421,7 +423,7 @@ class BrokerConnection(object): # old ssl in python2.6 will swallow all SSLErrors here... except (SSLWantReadError, SSLWantWriteError): pass - except (SSLZeroReturnError, ConnectionError): + except (SSLZeroReturnError, ConnectionError, SSLEOFError): log.warning('SSL connection closed by server during handshake.') self.close(Errors.ConnectionError('SSL connection closed by server during handshake')) # Other SSLErrors will be raised to user -- cgit v1.2.1