ros_comm
ros_comm copied to clipboard
Fix error reporting TCPROSServer
Stumbled across this little bug while hunting for another one
Can you describe the bug that this is fixing please?
@g-gemignani The fix looks reasonable, but I agree with Michael a little context would help. In what situation did you face an error? How did it manifest?
Hi and thank you for the answer. Yes, you are right, I was in a rush when I opened the fix and did not attach more info. Here it is: I was debugging a python interactive CLI that was spawning ros nodes in child processes upon issuing commands. The library was using multiprocessing (https://docs.python.org/3/library/multiprocessing.html). The issue that I was getting was a cascade of:
Inbound TCP/IP connection failed: can't concat dict to bytes Inbound TCP/IP connection failed: can't concat dict to bytes Inbound TCP/IP connection failed: can't concat dict to bytes Inbound TCP/IP connection failed: can't concat dict to bytes Inbound TCP/IP connection failed: can't concat dict to bytes Inbound TCP/IP connection failed: can't concat dict to bytes Inbound TCP/IP connection failed: can't concat dict to bytes Inbound TCP/IP connection failed: can't concat dict to bytes
After digging a bit, I found out that the issue was in ros_comm:
Traceback (most recent call last): File "/home/toru/catkin_ws/install/lib/python3/dist-packages/rospy/impl/tcpros_base.py", line 350, in _tcp_server_callback write_ros_handshake_header(sock, {'error' : err_msg}) File "/home/toru/catkin_ws/install/lib/python3/dist-packages/rosgraph/network.py", line 416, in write_ros_handshake_header s = encode_ros_handshake_header(header) File "/home/toru/catkin_ws/install/lib/python3/dist-packages/rosgraph/network.py", line 403, in encode_ros_handshake_header fields = [k + b"=" + v for k, v in sorted(encoded_header.items())] File "/home/toru/catkin_ws/install/lib/python3/dist-packages/rosgraph/network.py", line 403, in
fields = [k + b"=" + v for k, v in sorted(encoded_header.items())] TypeError: can't concat dict to bytes Inbound TCP/IP connection failed: can't concat dict to bytes
where encoder_header was:
{b'error': {'error': 'unhandled connection'}}
and this line of code was expecting encoder_header to be a dict[str: str].
Hence, the fix.
Please let me know if you need more info!
Is there a way to reproduce the problem?
I tried to reproduce the issue but failed to do so. If you do not think that this fix is worth merging, feel free to decline it. Up to you :)
I'm not a maintainer of rospy, so I'll leave that decision on @mjcarroll .