0
$\begingroup$

Rosanswers logo

I'm wondering if anybody has a method to restrict ROS 2 to use only the localhost for communication? Maybe there is (or at least could be) an environment variable to control this?

While setting ROS_DOMAIN_ID works fine to prevent collisions, it would be nice if this did not have to be set manually for cases where we know that the communication is only going to be within the machine.


Originally posted by allenh1 on ROS Answers with karma: 3055 on 2019-09-23

Post score: 1


Original comments

Comment by MCornelis on 2019-09-23:
I'm confused what you are trying to achieve? If you want to use intra-process communication have a look at this PR https://github.com/ros2/rclcpp/pull/778 . You can set nodes to use intra-process communication by passing rclcpp::NodeOptions().use_intra_process_comms(true) into the node. I.e.

auto node = std::make_shared<rclcpp::Node>("node_" + std::to_string(n), rclcpp::NodeOptions().use_intra_process_comms(true));

I believe it is also possible to set intra-process communication at a subscriber or publisher level, but I haven't tried this yet.

Comment by MCornelis on 2019-09-23:
Right now it does not support transient(-local) durability so you may have to change your QoS profile to VOLATILE for durability.

static const rclcpp::QoS qos = rclcpp::QoS(1)
                                   .reliability(RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT)
                                   .durability(RMW_QOS_POLICY_DURABILITY_VOLATILE);

Comment by allenh1 on 2019-09-23:
Sorry, @MCornelis, I think I could have been more clear in my wording... I'm not referring to intra-process communication, I'm more referring to restricting DDS discovery to only the local subnet.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Since ROS 2 Eloquent you can restrict all communication of an RMW implementation to localhost using the environment variable ROS_LOCALHOST_ONLY (see https://index.ros.org/doc/ros2/Releases/Release-Eloquent-Elusor/#new-features-in-this-ros-2-release).


Originally posted by Dirk Thomas with karma: 16276 on 2020-08-10

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Hakaishin on 2022-02-28:
This does not work for me

Comment by kmhallen on 2022-09-07:
For me it prevents traffic out to others, but it doesn't prevent discovery and traffic in from others

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.