ros_comm icon indicating copy to clipboard operation
ros_comm copied to clipboard

Fix error reporting TCPROSServer

Open g-gemignani opened this issue 2 years ago • 6 comments

Stumbled across this little bug while hunting for another one

g-gemignani avatar Nov 18 '22 08:11 g-gemignani

Can you describe the bug that this is fixing please?

mjcarroll avatar Jan 27 '23 14:01 mjcarroll

@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?

peci1 avatar Apr 09 '23 19:04 peci1

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!

g-gemignani avatar Apr 13 '23 11:04 g-gemignani

Is there a way to reproduce the problem?

peci1 avatar Apr 13 '23 11:04 peci1

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 :)

g-gemignani avatar Apr 13 '23 12:04 g-gemignani

I'm not a maintainer of rospy, so I'll leave that decision on @mjcarroll .

peci1 avatar Apr 13 '23 13:04 peci1