ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

rosbridge cannot connect to secure websocket, timed out error

asked 2015-04-13 04:58:28 -0500

giulatona gravatar image

I am using rosbridge and roslibjs to connect to ros. I wrote an HTML page that publishes a simple std_msgs::String message. I need to serve this page through HTTPS, therefore I have to connect to rosbridge through the wss protocol. Using simple http and ws it all works, but then I switch to the secure protocol i get the following error in the javascript console:

WebSocket connection to 'wss://localhost:9090/' failed: Error in connection establishment: net::ERR_TIMED_OUT

I serve the web page using apache default-ssl site and start rosbridge as follows:

roslaunch rosbridge_server rosbridge_websocket.launch ssl:=true certfile:=/etc/ssl/certs/ssl-cert-snakeoil.pem keyfile:=/etc/ssl/private/ssl-cert-snakeoil.key authenticate:=false

To connect to rosbridge I use:

  $(document).ready(function(){   var ros = new ROSLIB.Ros({
     url : 'wss://localhost:9090'    });

   ros.on('connection', function() {
     console.log('Connected to websocket server.');    });
   ros.on('error', function(error) {
     console.log('Error connecting to websocket server: ', error);    });
   ros.on('close', function() {
     console.log('Connection to websocket server closed.');    });  

I am running ROS Groovy on Ubuntu 12.04 on a x86 machine. I am using rosbridge version 0.5.6-1precise-20140906-1447-+0000

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-05-18 10:07:16 -0500

giulatona gravatar image

updated 2015-05-18 10:07:40 -0500

I found the solution. The problem was caused by missing read permission on the key file /etc/ssl/private/ssl-cert-snakeoil.key. After copying that file in my home folder and setting the right permissions the connection to the websocket went through properly.

edit flag offensive delete link more



can you tell us the steps? I got the same problem, but copying /etc/ssl/private/ssl-cert-snakeoil.key file to my home directory and changing permissions didn't work for me.

cooper gravatar image cooper  ( 2020-04-10 00:01:06 -0500 )edit

answered 2015-05-11 18:58:04 -0500

Joseph Landau gravatar image

If you are using a self-signed certificate, this occurs because the browser thinks the connection is insecure. I think maybe snakeoil has the same problem. Using the same browser and the same web address including the port numer, but with https replacing wss, attempt to connect manually from the address bar. You should get the dialog that allows you to accept the insecure connection. After that, the wss connection works. At least for me.

edit flag offensive delete link more


Thank you for your answer, but it does not seem to work for me. I tried to connect to the resource and I just get a ERR_TIMED_OUT. Did you tried it with ROS Groovy too?

giulatona gravatar image giulatona  ( 2015-05-12 09:54:23 -0500 )edit

No, I was using ROS hydro. I have the impression that the behavior we noted was coming from the browser, not from ROS. However, I have not tested that. Sorry it didn't help.

Joseph Landau gravatar image Joseph Landau  ( 2015-05-12 12:17:19 -0500 )edit

You were right in thinking that the behavior was not due to rosbridge. In fact, as I wrote in my answer, the problem was with the read permission on the key file. However it would have helped if rosbridge hed reported that it was unable to open the file.

giulatona gravatar image giulatona  ( 2015-05-18 10:10:13 -0500 )edit

Question Tools



Asked: 2015-04-13 04:58:28 -0500

Seen: 3,522 times

Last updated: May 18 '15