Skip to content

Commit 3ebdcba

Browse files
Ormod88manpreet
authored andcommitted
conn: Catch ssl.EOFErrors on Python3.3 so we close the failing conn (dpkp#1162)
1 parent a4339a8 commit 3ebdcba

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kafka/conn.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import ssl
3636
ssl_available = True
3737
try:
38+
SSLEOFError = ssl.SSLEOFError
3839
SSLWantReadError = ssl.SSLWantReadError
3940
SSLWantWriteError = ssl.SSLWantWriteError
4041
SSLZeroReturnError = ssl.SSLZeroReturnError
@@ -43,6 +44,7 @@
4344
log.debug('Old SSL module detected.'
4445
' SSL error handling may not operate cleanly.'
4546
' Consider upgrading to Python 3.3 or 2.7.9')
47+
SSLEOFError = ssl.SSLError
4648
SSLWantReadError = ssl.SSLError
4749
SSLWantWriteError = ssl.SSLError
4850
SSLZeroReturnError = ssl.SSLError
@@ -429,7 +431,7 @@ def _try_handshake(self):
429431
# old ssl in python2.6 will swallow all SSLErrors here...
430432
except (SSLWantReadError, SSLWantWriteError):
431433
pass
432-
except (SSLZeroReturnError, ConnectionError):
434+
except (SSLZeroReturnError, ConnectionError, SSLEOFError):
433435
log.warning('SSL connection closed by server during handshake.')
434436
self.close(Errors.ConnectionError('SSL connection closed by server during handshake'))
435437
# Other SSLErrors will be raised to user

0 commit comments

Comments
 (0)