From 274c9e73ba0aac686ac6dad306e81e8bbdd99e4f Mon Sep 17 00:00:00 2001 From: Matt Vollrath Date: Mon, 18 May 2020 22:26:32 -0400 Subject: [PATCH 1/2] websocket: Better shutdown exception handling Prevents errors during protocol shutdown from breaking other states. --- .../src/rosbridge_server/autobahn_websocket.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rosbridge_server/src/rosbridge_server/autobahn_websocket.py b/rosbridge_server/src/rosbridge_server/autobahn_websocket.py index 9af0f29ae..deb651cbf 100755 --- a/rosbridge_server/src/rosbridge_server/autobahn_websocket.py +++ b/rosbridge_server/src/rosbridge_server/autobahn_websocket.py @@ -245,8 +245,12 @@ def onClose(self, was_clean, code, reason): return # Closed before connection was opened. cls = self.__class__ cls.clients_connected -= 1 - self.protocol.finish() - self.incoming_queue.finish() + if cls.client_manager: cls.client_manager.remove_client(self.client_id, self.peer) rospy.loginfo("Client disconnected. %d clients total.", cls.clients_connected) + + try: + self.protocol.finish() + finally: + self.incoming_queue.finish() From 93ec91c9b1c1be05db657e3086e71fb711ef20b9 Mon Sep 17 00:00:00 2001 From: Matt Vollrath Date: Tue, 19 May 2020 18:26:25 -0400 Subject: [PATCH 2/2] Finish protocol in IncomingQueue thread --- .../src/rosbridge_server/autobahn_websocket.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rosbridge_server/src/rosbridge_server/autobahn_websocket.py b/rosbridge_server/src/rosbridge_server/autobahn_websocket.py index deb651cbf..7cf5c46c7 100755 --- a/rosbridge_server/src/rosbridge_server/autobahn_websocket.py +++ b/rosbridge_server/src/rosbridge_server/autobahn_websocket.py @@ -108,6 +108,8 @@ def run(self): self.protocol.incoming(msg) + self.protocol.finish() + @implementer(interfaces.IPushProducer) class OutgoingValve: @@ -250,7 +252,4 @@ def onClose(self, was_clean, code, reason): cls.client_manager.remove_client(self.client_id, self.peer) rospy.loginfo("Client disconnected. %d clients total.", cls.clients_connected) - try: - self.protocol.finish() - finally: - self.incoming_queue.finish() + self.incoming_queue.finish()