Port numbers used by ROS (in WSL env)
dkalog opened this issue · comments
Hi ,
do you know which ports number are used by ROS (service) ? I am trying to call a ROS service inside a WSL while doing port forwarding, but the port number keeps changing.. Is there any way to mitigate this ?
The ROS master uses port 11311 by default. You can change this by passing the --port
option to roscore
and by setting a different port in your ROS_MASTER_URI
. Note that ports below 1024 usually require root privileges.
Each ROS node sets up a few listening TCP sockets on random ports, one to service XML-RPC calls from the ROS master and other nodes, and one or several for topic connections and services. These ports are randomly allocated by the OS, so it's not possible to know what they will be ahead of time.
If you are using WSL2, there may be conflicts between netsh interface portproxy
and the WSL "magic" port forwarders attempting to start listening on the same (TCP) port⁴. You can try using a port forwarding script on login, but this is probably not a good option for ROS, since the port numbers are randomly assigned⁵. Another option is to use WSL 1 instead of WSL2.