[Help] How to connect the Rosbridge WebSocket server from a JS web app in another Wifi internet?

asked 2022-11-24 01:31:46 -0500

tflam gravatar image

My network setup:

image description

Situation:

I've created a web app using roslibjs.

It successfully connects the robot through the robot's wifi LAN (I have a small router inside the robot). The web application server (I used python3 -m http.server command to host it) and ROS are inside the robot's NUC. The web application is used on the mobile device, the mobile device is connected to the the robot's wifi LAN (Same Wifi of the robot).

However, if I bring the mobile device and walk outside the coverage of the robot's wifi LAN, the connection would be disconnected. In order to fix this problem, I want the web application to be hosted on the cloud or another PC and I use Ngrok to expose the PC's localhost to the public internet.

So now I can use my mobile to access the web application no matter how far I am. The problem is although I can use the web app on the mobile device outside the robot's wifi coverage, the websocket inside the web app (Written in JS using roblibjs) is not working. The console just prompt: fails to connect WebSocket.

Can anyone give me advice on the network setup? I want to use the web app no matter how far I am distanced from the robot, and the websocket keeps connecting to the robot's rosbridge WebSocket server. How can I achieve this goal?

I'll appreciate your help!

edit retag flag offensive close merge delete