Connection refused - docker to docker
Hi,
I am trying to establish ros connection between 2 dockers. Details given below.
Lets consider I have
docker_1
anddocker_2
.I am able to publish message from
docker_1
and subscribe it todocker_2
provided myroscore
is running indocker_1
.When I try to publish message from
docker_2
and subscribe it fromdocker_1
I am getting the below error.
Error:
[ERROR] [WallTime: 1553869754.845807] Unable to connect subscriber to publisher [http://172.17.0.1:44027/] for topic [/check]: unable to requestTopic: [Errno 111] Connection refused
IP details:
docker_1 :
ROS_MASTER_URI = http://172.17.0.1:11311
ROS_IP = 172.17.0.1
==========================================
docker_2 :
ROS_MASTER_URI = http://172.17.0.1:11311
ROS_IP = 172.17.0.1
Could you please help me to fix this.
Thank you, KK
Asked by kk2105 on 2019-03-29 09:35:14 UTC
Answers
Can you post your Docker file and/or your docker-compose.yml file?
Some things to consider:
- Are the containers communicating through the host OS?
- Or are you using a docker bridge network?
- Have you exposed the appropriate ports using Docker?
Asked by letsbelopez on 2019-03-30 11:29:58 UTC
Comments
Thanks for the answer. Please find the response below: Are the containers communicating through the host OS? - No Or are you using a docker bridge network? - No Have you exposed the appropriate ports using Docker? - Yes
Asked by kk2105 on 2019-04-03 21:58:10 UTC
If you're not using a bridge network, I think they must be using the host OS or how else would the containers be able to communicate?
Can you edit your question and post the Docker file and the docker-compose.yml file if you have one or link to your code.
Asked by letsbelopez on 2019-04-04 23:53:09 UTC
@letsbelopez Thanks for the reply. I was able to establish the communication by following the below steps:
docker_1 :
ROS_MASTER_URI = http://docker_1_IP:11311
ROS_IP = docker_1_IP
docker_2 :
ROS_MASTER_URI = http://docker_1_IP:11311
ROS_IP = docker_2_IP
Dockers where able to communicate, however if I have to send msg from docker 2 to 1, subscriber in the docker 1 needs to be started first. Is this the right way to do ?
Asked by kk2105 on 2019-04-05 04:53:47 UTC
It looks like you followed similar instructions to running ROS on two machines The two docker containers are sharing the same ros master, and are now able to communicate. The way ROS is built, it should not matter what node (publisher or subscriber) is started first. However, the subscriber will miss all messages sent before it was started. There are more nuances to this but this is the basic use case.
Asked by letsbelopez on 2019-04-05 09:53:28 UTC
@letsbelopez Could you help me with the better ways to do this if any. Also I have tried sending the message from slave to master, if I start the subscriber in the master after the publisher in the slave, I do not see any message being received in master end.
Asked by kk2105 on 2019-04-07 23:51:16 UTC
Comments