From 9d7b6d2df7677d848293596af8dfb55a98c1f6f9 Mon Sep 17 00:00:00 2001 From: gemignani Date: Fri, 18 Nov 2022 09:42:37 +0100 Subject: [PATCH] Fix error reporting TCPROSServer --- clients/rospy/src/rospy/impl/tcpros_base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clients/rospy/src/rospy/impl/tcpros_base.py b/clients/rospy/src/rospy/impl/tcpros_base.py index 430bca9d04..c8e2fa193b 100644 --- a/clients/rospy/src/rospy/impl/tcpros_base.py +++ b/clients/rospy/src/rospy/impl/tcpros_base.py @@ -322,17 +322,21 @@ def _tcp_server_callback(self, sock, client_addr): header = read_ros_handshake_header(sock, StringIO(), buff_size) else: header = read_ros_handshake_header(sock, BytesIO(), buff_size) - + if 'topic' in header: err_msg = self.topic_connection_handler(sock, client_addr, header) elif 'service' in header: err_msg = self.service_connection_handler(sock, client_addr, header) else: err_msg = 'no topic or service name detected' + + if isinstance(err_msg, dict): + err_msg = err_msg.get('error', 'unhandled connection') + if err_msg: # shutdown race condition: nodes that come up and down # quickly can receive connections during teardown. - + # We use is_shutdown_requested() because we can get # into bad connection states during client shutdown # hooks.