Ask Your Question
0

Can't establish connection to Web Server using rosbridge

asked 2020-04-01 03:36:39 -0600

saintdere gravatar image

updated 2020-07-21 02:13:43 -0600

I have created a simple HTML page to control the movement of a simulated Gazebo Turtlebot using roslaunch rosbridge_server rosbridge_websocket.launch following this tutorial. However, in the Web Console of the HTML page (F12) it shows the error "Firefox cant establish a connection to the server at ws://localhost:9090/." I am using the default rosbridge for the websocket(9090). In the Terminal I am also receiving the errors:

[-] failing WebSocket opening handshake ('WebSocket connection denied: origin 'null' not allowed') 

[-] dropping connection to peer tcp4:127.0.0.1:41290 with abort=False: WebSocket connection denied: origin 'null' not allowed.

Running ROS Melodic on Ubuntu 18.04

edit retag flag offensive close merge delete

Comments

I have the same problem¡¡¡, and i don't know hoy to solve it :(

martamm gravatar image martamm  ( 2020-04-02 10:59:09 -0600 )edit

Same error on other browser?

billy gravatar image billy  ( 2020-04-02 12:08:56 -0600 )edit
1

I have the same error on chromium, but in this case, is:

failing WebSocket opening handshake ('WebSocket connection denied: origin 'file://' not allowed') 
dropping connection to peer tcp4:127.0.0.1:41290 with abort=False: WebSocket connection denied: origin 'file://' not allowed.
martamm gravatar image martamm  ( 2020-04-02 14:11:15 -0600 )edit

I just tested exactly how it is outlined in the tutorial you used and it worked for me except that I needed to change URL of roslibjs and EventEmitter2 scripts as specified in official ROS tutorial.

As far as localhost connection everything worked. There must be something on your PC preventing local connection. Are you following exactly tutorial exactly and running ROS on the host and not inside of Docker container for example ?

I just realized that I am running with Chrome browser on Ubuntu 16.04 though so maybe Chrome browser is stricter with more web security features running on newer Ubuntu OS... or ROS Melodic web socket server has stricter web security features...

viktor.holova gravatar image viktor.holova  ( 2020-04-02 14:55:01 -0600 )edit

In my code I have exactly the URL that specified in ROS tutorial, and don't work :(

martamm gravatar image martamm  ( 2020-04-03 01:23:47 -0600 )edit

On Chrome I receive this error in the Web Console : WebSocket connection to 'ws://0.0.0.0:9090/' failed: Establishing a tunnel via proxy server failed. d.connect @ roslib.min.js:1 but no error in Terminal.

saintdere gravatar image saintdere  ( 2020-04-03 01:50:55 -0600 )edit

try install rosbridge 0.11.1

https://github.com/RobotWebTools/rosb...

jeon gravatar image jeon  ( 2020-04-03 05:58:47 -0600 )edit

It makes me an error when I execute the launch file rosbridge_websocket.launch

martamm gravatar image martamm  ( 2020-04-06 09:58:20 -0600 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-04-03 08:20:37 -0600

Websocket server in ROS Melodic version of rosbridge-server enforces more web security then older versions. Therefore, you are not able to connect to the rosbridge-server from a HTML page that is not served from the same origin.

That is, if you simply try to open your HTML page directly from a file on your local PC then websocket connection will fail because websocket server inside of rosbridge-server will refuse such connection.

The way to solve connection issue is to have a web server serving your HTML page which you want to do eventually for your system anyway.

Here you have options. For example:

1) For simple tests running on your local Ubuntu 18.04 you can serve your HTML page(s) by running simple HTTP server provided by Python3 on your Ubuntu (see this answer)

cd /my/html/files  #directory where your HTML page is located
python3 -m http.server 8080

Then you can run your page by pointing any browser to http://localhost:8080/your_page.html (tested in both FireFox and Chrome)

2) Eventually if would like to have ROS-based system using this technology you can consider using roswww ROS package to serve your application's HTML pages. We have been successfully using it for a few years now

edit flag offensive delete link more

Comments

it works thankssss

martamm gravatar image martamm  ( 2020-04-06 10:23:32 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-04-01 03:36:39 -0600

Seen: 2,610 times

Last updated: Jul 21 '20