From 29c61a4024c48cbc5bbc4d9464713ac73cb9074f Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Fri, 21 Apr 2023 10:29:36 +0200 Subject: python-stream: Handle SSL error in do_handshake. In some cases ovsdb server or relay gets restarted, ovsdb python clients may keep the local socket open. Instead of reconnecting a lot of failures will be logged. This can be reproduced with ssl connections to the server/relay and restarting it, so it has the same IP after restart. This patch catches the Exceptions at do_handshake to recreate the connection on the client side. Reviewed-by: Simon Horman Signed-off-by: Stefan Hoffmann Signed-off-by: Luca Czesla Signed-off-by: Max Lamprecht Co-authored-by: Luca Czesla Co-authored-by: Max Lamprecht Signed-off-by: Ilya Maximets --- python/ovs/stream.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/ovs/stream.py b/python/ovs/stream.py index ac5b0fd0c..b32341076 100644 --- a/python/ovs/stream.py +++ b/python/ovs/stream.py @@ -824,7 +824,8 @@ class SSLStream(Stream): self.socket.do_handshake() except ssl.SSLWantReadError: return errno.EAGAIN - except ssl.SSLSyscallError as e: + except (ssl.SSLSyscallError, ssl.SSLZeroReturnError, + ssl.SSLEOFError, OSError) as e: return ovs.socket_util.get_exception_errno(e) return 0 -- cgit v1.2.1