summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2021-06-07 16:19:01 -0400
committermorpheus65535 <[email protected]>2021-06-07 16:19:01 -0400
commit23ede4e7f9a69c6cc6f8545d90789457eb0d6c9a (patch)
tree4d32f4a5cac656039b1b5fae2cf7a7a05ced6925
parentcb09f8d4405d4a873cd9097924fe4da932cbfed4 (diff)
downloadbazarr-23ede4e7f9a69c6cc6f8545d90789457eb0d6c9a.tar.gz
bazarr-23ede4e7f9a69c6cc6f8545d90789457eb0d6c9a.zip
Updated signalrcore module following PR #61 merging.
-rw-r--r--libs/signalrcore/protocol/messagepack_protocol.py3
-rw-r--r--libs/signalrcore/transport/websockets/websocket_transport.py20
2 files changed, 15 insertions, 8 deletions
diff --git a/libs/signalrcore/protocol/messagepack_protocol.py b/libs/signalrcore/protocol/messagepack_protocol.py
index 45651e4b7..f70349aa8 100644
--- a/libs/signalrcore/protocol/messagepack_protocol.py
+++ b/libs/signalrcore/protocol/messagepack_protocol.py
@@ -56,6 +56,9 @@ class MessagePackHubProtocol(BaseHubProtocol):
data = json.loads(handshake_data)
return HandshakeResponseMessage(data.get("error", None)), messages
except Exception as ex:
+ if type(raw_message) is str:
+ data = json.loads(raw_message[0: raw_message.index("}") + 1])
+ return HandshakeResponseMessage(data.get("error", None)), []
Helpers.get_logger().error(raw_message)
Helpers.get_logger().error(ex)
raise ex
diff --git a/libs/signalrcore/transport/websockets/websocket_transport.py b/libs/signalrcore/transport/websockets/websocket_transport.py
index 7456b4b3f..e29c72344 100644
--- a/libs/signalrcore/transport/websockets/websocket_transport.py
+++ b/libs/signalrcore/transport/websockets/websocket_transport.py
@@ -128,9 +128,9 @@ class WebsocketTransport(BaseTransport):
self.connection_checker.start()
else:
self.logger.error(msg.error)
- self.on_socket_error(msg.error)
+ self.on_socket_error(self._ws, msg.error)
self.stop()
- raise ValueError("Handshake error {0}".format(msg.error))
+ self.state = ConnectionState.disconnected
return messages
def on_open(self, _):
@@ -138,11 +138,15 @@ class WebsocketTransport(BaseTransport):
msg = self.protocol.handshake_message()
self.send(msg)
- def on_close(self, _):
+ def on_close(self, callback, close_status_code, close_reason):
self.logger.debug("-- web socket close --")
+ self.logger.debug(close_status_code)
+ self.logger.debug(close_reason)
self.state = ConnectionState.disconnected
if self._on_close is not None and callable(self._on_close):
self._on_close()
+ if callback is not None and callable(callback):
+ callback()
def on_reconnect(self):
self.logger.debug("-- web socket reconnecting --")
@@ -150,7 +154,7 @@ class WebsocketTransport(BaseTransport):
if self._on_close is not None and callable(self._on_close):
self._on_close()
- def on_socket_error(self, _, error):
+ def on_socket_error(self, app, error):
"""
Args:
_: Required to support websocket-client version equal or greater than 0.58.0
@@ -160,15 +164,15 @@ class WebsocketTransport(BaseTransport):
HubError: [description]
"""
self.logger.debug("-- web socket error --")
- self.logger.error(traceback.format_exc(5, True))
+ self.logger.error(traceback.format_exc(10, True))
self.logger.error("{0} {1}".format(self, error))
self.logger.error("{0} {1}".format(error, type(error)))
self._on_close()
- raise HubError(error)
+ self.state = ConnectionState.disconnected
+ #raise HubError(error)
- def on_message(self, _, raw_message):
+ def on_message(self, app, raw_message):
self.logger.debug("Message received{0}".format(raw_message))
- self.connection_checker.last_message = time.time()
if not self.handshake_received:
messages = self.evaluate_handshake(raw_message)
if self._on_open is not None and callable(self._on_open):