You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Subscribing & Publishing from ROS nodes does not work #1391
When comparing them, the HTTP response received immediately before the error message is emitted does have a nonzero body. In fact the body length is identical on WSL and Ubuntu 16.04...
... logging to /home/jan/.ros/log/bbcd1c24-d78a-11e6-a37c-74d435eb8bb7/roslaunch-jan-pc-1192.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://jan-pc:3024/
ros_comm version 1.12.6
SUMMARY
========
PARAMETERS
* /rosdistro: kinetic
* /rosversion: 1.12.6
NODES
auto-starting new master
process[master]: started with pid [1238]
ROS_MASTER_URI=http://jan-pc:11311/
setting /run_id to bbcd1c24-d78a-11e6-a37c-74d435eb8bb7
process[rosout-1]: started with pid [1251]
started core service [/rosout]
roswtf yields
Loaded plugin tf.tfwtf
No package or stack in context
================================================================================
Static checks summary:
No errors or warnings
================================================================================
Beginning tests of your ROS graph. These may take awhile...
analyzing graph...
... done analyzing graph
running graph rules...
... done running graph rules
Online checks summary:
Found 1 warning(s).
Warnings are things that may be just fine, but are sometimes at fault
WARNING The following node subscriptions are unconnected:
* /rosout:
* /rosout
Again, roswtf complains about the unconnected subscription of /rosout.
Finally, rostopic echo /rosout yields
[WARN] [1484090178.231790]: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.
header:
seq: 1
stamp:
secs: 1484090178
nsecs: 232148885
frame_id: ''
level: 4
name: /rostopic_1302_1484090177803
msg: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.
file: tcpros_base.py
function: _tcp_server_callback
line: 351
topics: ['/rosout']
---
I still get [WARN] [1486081593.661951]: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.
from rospy_tutorial listener, once per node, though which seem to originate from ros_comm/tools/rosgraph/src/rosgraph/network.py line: 364.
It looks like that the TCP connection from rosout(forked from roscore) to rostopic is closed before established, as shown below:
[rosout as TCP client][pid 4267] 1494264440.613661 connect(12, {sa_family=AF_INET, sin_port=htons(13277), sin_addr=inet_addr("127.0.1.1")}, 16) = 0
[rosout as TCP client][pid 4267] 1494264440.614272 shutdown(12, SHUT_RDWR) = 0
[rostopic as TCP server][pid 4515] 1494264440.614276 <... accept resumed> {sa_family=AF_INET, sin_port=htons(13283), sin_addr=inet_addr("127.0.0.1")}, [16]) = 7
[rostopic as TCP server][pid 4515] 1494264440.617155 recvfrom(7, "", 4096, 0, NULL, NULL) = 0
[rostopic as TCP server][WARN] [1494264440.618661]: Inbound TCP/IP connection failed(debug): connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.
Server python code which raise exception(/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/network.py):
def read_ros_handshake_header(sock, b, buff_size):
"""
Read in tcpros header off the socket \a sock using buffer \a b.
:param sock: socket must be in blocking mode, ``socket``
:param b: buffer to use, ``StringIO`` for Python2, ``BytesIO`` for Python 3
:param buff_size: incoming buffer size to use, ``int``
:returns: key value pairs encoded in handshake, ``{str: str}``
:raises: :exc:`ROSHandshakeException` If header format does not match expected
"""
header_str = None
while not header_str:
d = sock.recv(buff_size)
if not d:
raise ROSHandshakeException("connection from sender terminated before handshake header received. %s bytes were received. Please check sender for additional details."%b.tell())
b.write(d)
btell = b.tell()
if btell > 4:
# most likely we will get the full header in the first recv, so
# not worth tiny optimizations possible here
bval = b.getvalue()
(size,) = struct.unpack('<I', bval[0:4])
if btell - 4 >= size:
header_str = bval
# memmove the remnants of the buffer back to the start
leftovers = bval[size+4:]
b.truncate(len(leftovers))
b.seek(0)
b.write(leftovers)
header_recvd = True
# process the header
return decode_ros_handshake_header(bval)
and /opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_base.py
def _tcp_server_callback(self, sock, client_addr):
"""
TCPServer callback: detects incoming topic or service connection and passes connection accordingly
@param sock: socket connection
@type sock: socket.socket
@param client_addr: client address
@type client_addr: (str, int)
@raise TransportInitError: If transport cannot be succesfully initialized
"""
#TODOXXX:rewrite this logic so it is possible to create TCPROSTransport object first, set its protocol,
#and then use that to do the writing
try:
buff_size = 4096 # size of read buffer
if python3 == 0:
#initialize read_ros_handshake_header with BytesIO for Python 3 (instead of bytesarray())
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 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.
if not rospy.core.is_shutdown_requested():
write_ros_handshake_header(sock, {'error' : err_msg})
raise TransportInitError("Could not process inbound connection: "+err_msg+str(header))
else:
write_ros_handshake_header(sock, {'error' : 'node shutting down'})
return
except rospy.exceptions.TransportInitError as e:
logwarn(str(e))
if sock is not None:
sock.close()
except Exception as e:
# collect stack trace separately in local log file
if not rospy.core.is_shutdown_requested():
logwarn("Inbound TCP/IP connection failed %s", e)
rospyerr("Inbound TCP/IP connection failed\n%s", traceback.format_exc())
if sock is not None:
sock.close()
_tcp_server_callback is called from below code
def run(self):
"""
Main TCP receive loop. Should be run in a separate thread -- use start()
to do this automatically.
"""
self.is_shutdown = False
if not self.server_sock:
raise ROSInternalException("%s did not connect"%self.__class__.__name__)
while not self.is_shutdown:
try:
(client_sock, client_addr) = self.server_sock.accept()
except socket.timeout:
continue
except IOError as e:
(errno, msg) = e.args
if errno == 4: #interrupted system call
continue
raise
if self.is_shutdown:
break
try:
#leave threading decisions up to inbound_handler
self.inbound_handler(client_sock, client_addr)
except socket.error as e:
if not self.is_shutdown:
traceback.print_exc()
logwarn("Failed to handle inbound connection due to socket error: %s"%e)
logdebug("TCPServer[%s] shutting down", self.port)
I'm new to ROS. I have not found the code of rosout which close the connection and cause this error.
Maybe someone else can help.
Just making sure: Kei Okada (@k-okada): did you test this with ROS pubs/subs running the a single machine only (ie: the WSL machine), or were there more involved? I ask because a critical fix for Kinetic hasn't been backported from Lunar yet (and another is being reviewed for Lunar) which -- in the past at least -- was absolutely required to get things working.
I tested ROS Kinetic about a week ago. It works in single machine but didn't work in multi machine bacause of the reason I mentioned in ros/ros_comm#1202.
I have open a new PR (ros/ros_comm#1202) to ros_comm (lunar-devel) several days ago to fix a bug about TransportTCP. I'm sure my PR completely solve this problem for both Lunar and Kinetic. I hava tested it in both single machine and multi machines.
G.A. vd. Hoorn (@gavanderhoorn) I upgraded ROS about a week ago. That version of ros_comm works in single machine. But It didn't work in multi machines ( I tested this about a week ago). I will test the latest version of ros_comm to check if it work in multi machines or not tomorrow.
PR ros/ros_comm#1050 may works in single machine but it didn't solve the problem completely. It didn't work in multi machines. : (
So I open the new PR ros/ros_comm#1202.
Update 2017/10/30:
The version of ros_comm in my WSL is 1.12.7 (latest). It doesn't work in multi machines.
Hey everyone. The issue still sometimes appears when using the ROSBridge TCP Server. That happens with ROS Kinetic and Melodic.
[WARN] [1542980586.269629, 1542980567.055869]: Inbound TCP/IP connection failed: timed out [WARN] [1542980586.273813, 1542980567.055869]: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.
I cannot exactly understand what the solution was to the initial problem, but it looks like it still exists to some degree in the rosbridge TCP server.
Windows: 1803
Ubuntu 16.04 and 18.04
ROS: Kinetic and Melodic
ros_comm version that comes with the respective versions of ROS.
Everything runs on a single machine.
In general it works most of the times. but sometimes the socket connection stops receiving/sending data and eventually a few seconds or minutes later the output I posted above is printed to the console. In the end even roswtf is not able to communicate with the rosbridge anymore. Which indicates, that the connection from the ROSBridge to the roscore is broken somehow. Sometimes I need to restart my computer to get it to work again. Restarting the roscore+tcp bridge or the app that communicates does not help most of the times to workaround this issue.
When I run natively in ubuntu 16 or 18 this never happened.
Richard Schubert (@Hemofektik)
As I mentioned in the PR ros/ros_comm#1202. If the socket connection is slow in WSL, roscore will try to recv() on a connecting socket. This will cause an error and the socket will be closed early.
Therefore, I suspect that under heavy load, the local socket connection may be slowed down, which may cause rosbridge to fail to connect to roscore.
You can run strace -ttt -f -e trace=network roscore to examine what happened in roscore or rosbridgeand check if it try to recv() on a connecting socket.
Hi there! I have just apt-installed ros kinetic on WSL Ubuntu 16.04. The python talker/listener example only works as long as I start both from the same bash. Is that still the issue here? Wasn't it fixed in October 2017?
A bit more on the symptoms:
I can run a roscore in one bash window, then in another I execute
and everything works as expected. When I run rostopic list from another bash window, it also shows the /chatter topic but neither listener.py nor rostopic echo receive anything.
Activity
janbernloehr commentedon Nov 19, 2016
#69, #134, #610, and #720 seem to be related. Maybe Sunil Muthuswamy (@sunilmut) can have a look into it?
gavanderhoorn commentedon Nov 20, 2016
This report is a bit too vague: the error message you include is ROS-specific, so isn't going to be much help to WSL devs.
I would include at least some
straceoutput that shows what is actually not working.The
rostopic echo ..binary exercises the entire networking stack of ROS, so that would be expected.janbernloehr commentedon Nov 20, 2016
here are the straces of roscore and rostopic. unfortunately i am not experienced in interpreting them.
rostopic.txt
roscore.txt
i will get hold of logs where everything works tomorrow
janbernloehr commentedon Nov 20, 2016
Here are two similar logs from a working Ubuntu 16.04 LTS + ROS Kinetic installation
roscore.txt
rostopic.txt
When comparing them, the HTTP response received immediately before the error message is emitted does have a nonzero body. In fact the body length is identical on WSL and Ubuntu 16.04...
janbernloehr commentedon Dec 11, 2016
The issue persists in 14986.
janbernloehr commentedon Jan 10, 2017
The issue persists in 15002.
Starting a roscore works with the output
roswtf yields
Again, roswtf complains about the unconnected subscription of /rosout.
Finally, rostopic echo /rosout yields
janbernloehr commentedon Jan 23, 2017
Same behavior on 15014.
Andersqqq commentedon Feb 3, 2017
While testing with roscpp and rospy talker_listener tutorial examples at https://github.com/ros/ros_tutorials on build 15025 it seems like rospy nodes works, but only sending works for roscpp (talker). I can run roscpp_tutorial talker together with rospy_tutorial listener.
I still get
[WARN] [1486081593.661951]: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.from rospy_tutorial listener, once per node, though which seem to originate from ros_comm/tools/rosgraph/src/rosgraph/network.py line: 364.
I ran strace on roscpp listener on wsl and my working ubuntu 16.04.
roslistener-ubuntu.txt
roslistener-wsl.txt
I would happy to provide any additional information need.
janbernloehr commentedon Mar 8, 2017
The issue persists in 15048
noldona commentedon Apr 13, 2017
Issue still exists in Version 1703 (OS Build 15063.138)
bxwllzz commentedon May 8, 2017
Issue still exists in Version 1703 (OS Build 16188.1000)
Part of
strace -ttt -f -e trace=network roscoreoutputs:Part of
strace -ttt -f -e trace=network rostopic pub /rosout std_msgs/String "hello there"outputs:It looks like that the TCP connection from
rosout(forked from roscore) torostopicis closed before established, as shown below:Server python code which raise exception(
/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/network.py):and
/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_base.py_tcp_server_callbackis called from below codeI'm new to ROS. I have not found the code of
rosoutwhich close the connection and cause this error.Maybe someone else can help.
bxwllzz commentedon May 9, 2017
I have determined the problem. The problem lies in the ROS.
Line 316 in ros_comm/roscpp/src/libros/transport/transport_tcp.cpp
It assumes that the
connectmethod of non-blocking scoket should return -1 andlast_socket_error()should returnROS_SOCKETS_ASYNCHRONOUS_CONNECT_RETURN(=EINPROGRESS).But a non-blocking
connectcan return 0 when TCP connection to 127.0.0.1 (localhost).http://stackoverflow.com/questions/14027326/can-connect-return-0-with-non-blocing-socket
gavanderhoorn commentedon May 9, 2017
Interesting. Have you tested this already by patching
ros_command running it on WSL? I'll try to do the same today.16 remaining items
gavanderhoorn commentedon Oct 29, 2017
Just making sure: Kei Okada (@k-okada): did you test this with ROS pubs/subs running the a single machine only (ie: the WSL machine), or were there more involved? I ask because a critical fix for Kinetic hasn't been backported from Lunar yet (and another is being reviewed for Lunar) which -- in the past at least -- was absolutely required to get things working.
bxwllzz commentedon Oct 29, 2017
G.A. vd. Hoorn (@gavanderhoorn) What's the critical fix you mentioned?
I tested ROS Kinetic about a week ago. It works in single machine but didn't work in multi machine bacause of the reason I mentioned in ros/ros_comm#1202.
I have open a new PR (ros/ros_comm#1202) to ros_comm (lunar-devel) several days ago to fix a bug about TransportTCP. I'm sure my PR completely solve this problem for both Lunar and Kinetic. I hava tested it in both single machine and multi machines.
gavanderhoorn commentedon Oct 29, 2017
The critical fix is your previous PR (ros/ros_comm#1050), which won't be available on Kinetic until ros/ros_comm#1205 is merged.
bxwllzz commentedon Oct 29, 2017
G.A. vd. Hoorn (@gavanderhoorn) I upgraded ROS about a week ago. That version of ros_comm works in single machine. But It didn't work in multi machines ( I tested this about a week ago). I will test the latest version of ros_comm to check if it work in multi machines or not tomorrow.
PR ros/ros_comm#1050 may works in single machine but it didn't solve the problem completely. It didn't work in multi machines. : (
So I open the new PR ros/ros_comm#1202.
Update 2017/10/30:
The version of
ros_commin my WSL is 1.12.7 (latest). It doesn't work in multi machines.k-okada commentedon Oct 29, 2017
yes, that's correct, and I haven't tested with multi machine environment.
rowanG077 commentedon Oct 29, 2017
ROS Lunar doesn't work for me.
See this issue: #2560
sunilmut commentedon Oct 30, 2017
Rowan Goemans (@rowanG077) - Point noted. Let's continue the discussion on #2560.
Hemofektik commentedon Nov 23, 2018
Hey everyone. The issue still sometimes appears when using the ROSBridge TCP Server. That happens with ROS Kinetic and Melodic.
[WARN] [1542980586.269629, 1542980567.055869]: Inbound TCP/IP connection failed: timed out [WARN] [1542980586.273813, 1542980567.055869]: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.I cannot exactly understand what the solution was to the initial problem, but it looks like it still exists to some degree in the rosbridge TCP server.
Any ideas where to look into to find the problem?
janbernloehr commentedon Nov 23, 2018
Can you share a little more detail on your environment? Windows version? Version of Ubuntu? Version of ros? Version of ros_comm?
Hemofektik commentedon Nov 23, 2018
Thanks for your fast reaction.
Windows: 1803
Ubuntu 16.04 and 18.04
ROS: Kinetic and Melodic
ros_comm version that comes with the respective versions of ROS.
Everything runs on a single machine.
In general it works most of the times. but sometimes the socket connection stops receiving/sending data and eventually a few seconds or minutes later the output I posted above is printed to the console. In the end even roswtf is not able to communicate with the rosbridge anymore. Which indicates, that the connection from the ROSBridge to the roscore is broken somehow. Sometimes I need to restart my computer to get it to work again. Restarting the roscore+tcp bridge or the app that communicates does not help most of the times to workaround this issue.
When I run natively in ubuntu 16 or 18 this never happened.
Hemofektik commentedon Nov 26, 2018
Any Ideas where I should look to find the culprit?
bxwllzz commentedon Nov 26, 2018
Richard Schubert (@Hemofektik)
As I mentioned in the PR ros/ros_comm#1202. If the socket connection is slow in WSL,
roscorewill try torecv()on a connecting socket. This will cause an error and the socket will be closed early.Therefore, I suspect that under heavy load, the local socket connection may be slowed down, which may cause
rosbridgeto fail to connect toroscore.You can run
strace -ttt -f -e trace=network roscoreto examine what happened inroscoreorrosbridgeand check if it try torecv()on a connecting socket.Hemofektik commentedon Nov 27, 2018
Thanks for your input. I will give it a try.
mqnc commentedon Jun 27, 2019
Hi there! I have just apt-installed ros kinetic on WSL Ubuntu 16.04. The python talker/listener example only works as long as I start both from the same bash. Is that still the issue here? Wasn't it fixed in October 2017?
A bit more on the symptoms:
I can run a roscore in one bash window, then in another I execute
or
and everything works as expected. When I run
rostopic listfrom another bash window, it also shows the /chatter topic but neitherlistener.pynorrostopic echoreceive anything.Any help appreciated!