rosbridge_suite icon indicating copy to clipboard operation
rosbridge_suite copied to clipboard

rosbridge_server bug with NAT ports mapping

Open rscova opened this issue 1 year ago • 1 comments

Description When you start the server in your IP address and you want to access the topics through your router's IP public address you need to map the ports (I did that using NAT). But the only way that this work is when you map the ports to match, I meant: Ports: 9090 -> 45666 (Bad behaviour, rosbridge_server doesn't recognize the connection) Ports: 45666 -> 45666 (Good behaviour, rosbridge_server recognizes the connection)

This is because even if you use NAT to remap the port, the client sends an HTTP header Host: publicip:45666 which rosbridge_server complains about.

My recommendation, at least, if you don't want to fix this bug, would be to add this info in the documentation.

  • Library Version: ros2 branch
  • ROS Version: Galactic
  • Platform / OS: Ubuntu 20.04

Steps To Reproduce

ros2 launch rosbridge_server rosbridge_websocket_launch.xml address:=192.168.1.x port:=9090

NAT remapping Ports 9090 to X (the one your router allows you)

Try to connect with WebSockets with Foxglove, or your own application using your router's public IP and the port remapped.

Expected Behavior You can connect with rosbridge_server

Actual Behavior You can't connect with rosbridge_server

rscova avatar Jul 15 '22 06:07 rscova

On ros (ros1), there was a similar problem when running rosbridge inside a docker container in which the port of the host was different from the port of the docker container.

In that case, it was enough to pass the websocket_external_port parameter, as explained in the link below.

https://github.com/RobotWebTools/rosbridge_suite/issues/529#issuecomment-713857597

However, for ROS2, the code in this repo does not have that parameter.

I know this is not a solution, but I'm telling you because this may give you some ideas.

rubenanapu avatar Sep 16 '22 21:09 rubenanapu