ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Publishing to ROS node running on different Computer

asked 2022-11-07 20:08:15 -0600

akumar3.1428 gravatar image

updated 2023-06-18 09:45:15 -0600

lucasw gravatar image

I would like to know how I can send data to different computer, I initiated with sending data into the same machine using the code. However, getting the following error message, is there a specific way on entering the IP address or any other requirement that needs to be taken care of before starting sending the message. Like do I need to install rosbridge and run it before sending the message.


[roslibrust::rosbridge::client] Failed to reconnect: CommFailure(Io(Os { code: 111, kind: ConnectionRefused, message: "Connection refused" }))


use log::*;
use roslibrust::ClientHandle;


/// This example creates a client, and publishes a message to the topic "talker"
/// Running this example at the same time as subscribe_and_log will have the two examples
/// pass messages between each other.
/// To run this example a rosbridge websocket server should be running at the deafult port (9090).
#[tokio::main(flavor = "multi_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
        .without_timestamps() // required for running wsl2

    let client = ClientHandle::new("ws://localhost:9080").await?;
    let publisher = client.advertise::<std_msgs::Header>("talker").await?;

    loop {
        let msg = std_msgs::Header::default();
        info!("About to publish");
        info!("Published msg...");
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-11-08 15:31:39 -0600

akumar3.1428 gravatar image

I figure out that It is essential to run rosbridge on the computer where you want to send data to. After installing rosbridge using the following command sudo apt-get install ros-<rosdistro>-rosbridge-server and launching using the command roslaunch rosbridge_server rosbridge_websocket.launch it was working perfectly. I would like to suggest to take care of the port number as rosbridge usually use 9090 and any different port number in the code could lead to error.

I am closing this issue as it has been solved. If the problem persists, please comment and the issue will be reopened if appropriate.

edit flag offensive delete link more

Question Tools



Asked: 2022-11-07 20:08:15 -0600

Seen: 125 times

Last updated: Nov 08 '22