From a795faa4eecc580c0017f99ce8ee25c75174f4d4 Mon Sep 17 00:00:00 2001 From: Alexander Sibiryakov Date: Wed, 15 Jul 2020 15:25:31 +0200 Subject: [PATCH 1/3] handling OSError --- kafka/conn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kafka/conn.py b/kafka/conn.py index c383123ca..836744997 100644 --- a/kafka/conn.py +++ b/kafka/conn.py @@ -507,7 +507,7 @@ def _try_handshake(self): # old ssl in python2.6 will swallow all SSLErrors here... except (SSLWantReadError, SSLWantWriteError): pass - except (SSLZeroReturnError, ConnectionError, TimeoutError, SSLEOFError): + except (SSLZeroReturnError, ConnectionError, TimeoutError, SSLEOFError, OSError): log.warning('SSL connection closed by server during handshake.') self.close(Errors.KafkaConnectionError('SSL connection closed by server during handshake')) # Other SSLErrors will be raised to user From 5b833354167ddcbffea0ed7ed43e478db2cb1b5e Mon Sep 17 00:00:00 2001 From: Alexander Sibiryakov Date: Wed, 15 Jul 2020 15:37:37 +0200 Subject: [PATCH 2/3] better error output --- kafka/conn.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kafka/conn.py b/kafka/conn.py index 836744997..8d676953f 100644 --- a/kafka/conn.py +++ b/kafka/conn.py @@ -507,7 +507,8 @@ def _try_handshake(self): # old ssl in python2.6 will swallow all SSLErrors here... except (SSLWantReadError, SSLWantWriteError): pass - except (SSLZeroReturnError, ConnectionError, TimeoutError, SSLEOFError, OSError): + except (SSLZeroReturnError, ConnectionError, TimeoutError, SSLEOFError, ssl.SSLError, OSError) as e: + log.exception(e) log.warning('SSL connection closed by server during handshake.') self.close(Errors.KafkaConnectionError('SSL connection closed by server during handshake')) # Other SSLErrors will be raised to user From f9eab05e61c6bf0b92a61136c815bb47dfc50121 Mon Sep 17 00:00:00 2001 From: Alexander Sibiryakov Date: Fri, 7 Aug 2020 10:29:37 +0200 Subject: [PATCH 3/3] removed traceback logging --- kafka/conn.py | 1 - 1 file changed, 1 deletion(-) diff --git a/kafka/conn.py b/kafka/conn.py index 8d676953f..43901a34b 100644 --- a/kafka/conn.py +++ b/kafka/conn.py @@ -508,7 +508,6 @@ def _try_handshake(self): except (SSLWantReadError, SSLWantWriteError): pass except (SSLZeroReturnError, ConnectionError, TimeoutError, SSLEOFError, ssl.SSLError, OSError) as e: - log.exception(e) log.warning('SSL connection closed by server during handshake.') self.close(Errors.KafkaConnectionError('SSL connection closed by server during handshake')) # Other SSLErrors will be raised to user