diff --git a/clients/rospy/src/rospy/impl/tcpros_base.py b/clients/rospy/src/rospy/impl/tcpros_base.py
index 430bca9d04..f5bbe58d23 100644
--- a/clients/rospy/src/rospy/impl/tcpros_base.py
+++ b/clients/rospy/src/rospy/impl/tcpros_base.py
@@ -322,17 +322,17 @@ 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)
+                err_msg = self.topic_connection_handler(sock, client_addr, header)['error']
             elif 'service' in header:
-                err_msg = self.service_connection_handler(sock, client_addr, header)
+                err_msg = self.service_connection_handler(sock, client_addr, header)['error']
             else:
                 err_msg = 'no topic or service name detected'
             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.