From 5db7a705c5b25d04b016f0302555b89d59db2eca Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 11 Aug 2023 22:31:03 +0100 Subject: [PATCH] log and rethrow TimeoutError on connection we can just encode challenge here. shorten opcode != 2 message --- obsws_python/baseclient.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/obsws_python/baseclient.py b/obsws_python/baseclient.py index ca9ac1e..27bcc09 100644 --- a/obsws_python/baseclient.py +++ b/obsws_python/baseclient.py @@ -43,7 +43,7 @@ class ObsClient: except ValueError as e: self.logger.error(f"{type(e).__name__}: {e}") raise - except (ConnectionRefusedError, WebSocketTimeoutException) as e: + except (ConnectionRefusedError, TimeoutError, WebSocketTimeoutException) as e: self.logger.exception(f"{type(e).__name__}: {e}") raise @@ -97,9 +97,9 @@ class ObsClient: auth = base64.b64encode( hashlib.sha256( ( - secret.decode() - + self.server_hello["d"]["authentication"]["challenge"] - ).encode() + secret + + self.server_hello["d"]["authentication"]["challenge"].encode() + ) ).digest() ).decode() @@ -110,7 +110,7 @@ class ObsClient: response = json.loads(self.ws.recv()) if response["op"] != 2: raise OBSSDKError( - "failed to identify client with the server, expected response with OpCode 2 Identified" + "failed to identify client with the server, expected response with OpCode 2" ) return response["d"] except json.decoder.JSONDecodeError: