main: Handle socket errors during the SSL handshake.

This commit is contained in:
Damir Jelić 2018-07-31 11:57:27 +02:00
parent 9e6bd0c246
commit 35e6978622

View file

@ -239,8 +239,11 @@ def try_ssl_handshake(server):
return False
except ssl.SSLError as error:
str_error = error.reason if error.reason else "Unknown error"
except (ssl.SSLError, socket.error) as error:
try:
str_error = error.reason if error.reason else "Unknown error"
except AttributeError:
str_error = str(error)
message = ("{prefix}Error while doing SSL handshake"
": {error}").format(
@ -250,7 +253,7 @@ def try_ssl_handshake(server):
server_buffer_prnt(
server, ("{prefix}matrix: disconnecting from server..."
).format(prefix=W.prefix("network")))
).format(prefix=W.prefix("network")))
server.disconnect()
return False