ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

Rosbridge: received a message without an op

asked 2022-09-20 15:14:53 -0600

tiho_bg gravatar image

updated 2022-09-22 05:56:10 -0600

ravijoshi gravatar image

I'm starting my web page from my laptop. The Web page is on my raspberry PI 4. I'm starting rosbridge_server from my raspberry PI too. I'm using ROS Noetic and Ubuntu 20.04. I'm trying to access raspberry PI from my laptop using my web page where I try to establish ssh connection.

I've received the following error:

Received a message without an op. All messages require 'op' field with value one of: ['call_service', 'advertise', 'unadvertise', 'publish', 'subscribe', 'unsubscribe', etc...]

How to resolve this issue?

Below is my html code:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <script type="text/javascript" src="http://static.robotwebtools.org/roslibjs/current/roslib.min.js"></script>
    <script type="text/javascript" type="text/javascript">
      var ros = new ROSLIB.Ros({
        url: "ws://192.168.100.34:8080",
      });
      var mainSocket = new WebSocket("ws://192.168.100.34:8080");
      mainSocket.onopen = function (event) {
        mainSocket.sent(JSON.stringify({ action: "connect", host: "ubiquityrobot", port: 22, username: "ubuntu", password: "ubuntu" }));
        document.getElementById("conn").innerHTML = "Socket open success";
      };
      ros.on("connection", function () {
        document.getElementById("status").innerHTML = "Connected";
      });
      ros.on("error", function (error) {
        document.getElementById("status").innerHTML = "Error";
      });
      ros.on("close", function () {
        document.getElementById("status").innerHTML = "Closed";
      });
    </script>
  </head>
  <body>
    <h1>Simple ROS User Interface</h1>
    <p>Connection status: <span id="status"></span></p>
    <p id="conn"></p>
  </body>
</html>
edit retag flag offensive close merge delete

Comments

Your code is not here, please edit your question + the more info about your setup, the better

ljaniec gravatar image ljaniec  ( 2022-09-20 17:22:29 -0600 )edit

First, you are connecting to rosbridge_server at ws://192.168.100.34:8080, and then you are creating a web socket at the same URI. Later you seem to send data to that socket. This is probably the cause of the error. You should not touch the URI for rosbridge_server again. Furthermore, the default port for rosbridge_server is 9090. If I remember correctly, port 8080 was used by tomcat in the past. I would not pick this port number for rosbridge_server.

ravijoshi gravatar image ravijoshi  ( 2022-09-22 06:07:53 -0600 )edit

Thank you for reply. Could you please help me to modify my code without touching the URI again? Thank you in advance!

tiho_bg gravatar image tiho_bg  ( 2022-09-22 11:29:02 -0600 )edit

I'm trying to access raspberry PI from my laptop using my web page where I try to establish ssh connection.

I am having a hard time understanding the above line.

Could you please help me to modify my code without touching the URI again?

Just remove var mainSocket = new WebSocket( ... ) and get rid of mainSocket.onopen = ... below.

ravijoshi gravatar image ravijoshi  ( 2022-09-22 23:00:30 -0600 )edit

Thank you for your reply! I think that if I remove

mainSocket.onopen = function (event) {
    mainSocket.sent(JSON.stringify({ action: "connect", host: "ubiquityrobot", port: 22, username: "ubuntu", password: "ubuntu" }));

I can't establish a connection with my raspberry PI. Normally I open the shell of Ubuntu and write ssh ubuntu@ubiquityrobot.local. Then I have to write the password and finally I can access my raspberry PI. I would like to make the same procedure with my webpage but without using the shell. Therefore I think that I need this function mainSocket.onopen = ...

tiho_bg gravatar image tiho_bg  ( 2022-09-22 23:44:55 -0600 )edit
1

I understand.

  1. Do you really need ssh access to the Raspberry PI using a WebSocket? Please think about it!
  2. You are using the same port, i.e., 8080, for two purposes, which is incorrect. By default, rosbridge_server and ssh runs on 9090 and 22 port, respectively. Please check and correct those port numbers.
  3. Lastly, it seems difficult to make an ssh connection using a WebSocket. I do not understand why someone would pick a WebSocket to connect to ssh. Please read a similar question asked in StackOverflow for further details.
ravijoshi gravatar image ravijoshi  ( 2022-09-23 00:03:02 -0600 )edit

These comments can be helpful for the future readers, please add them as an answer + move the discussion with @tiho_bg here

ljaniec gravatar image ljaniec  ( 2022-09-23 07:38:53 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-09-23 11:08:02 -0600

ravijoshi gravatar image

updated 2022-09-23 11:11:19 -0600

First, you are connecting to rosbridge_server at ws://192.168.100.34:8080, and then you are creating a WebSocket at the same URI. Later you seem to send data to that socket. This is probably the cause of the error. You should not touch the URI for rosbridge_server again. Furthermore, the default port for rosbridge_server is 9090. If I remember correctly, port 8080 was used by tomcat in the past. So, I would not pick this port number for rosbridge_server.

Normally I open the shell of Ubuntu and write ssh ubuntu@ubiquityrobot.local. Then I have to write the password and finally I can access my raspberry PI. I would like to make the same procedure with my webpage but without using the shell. Therefore I think that I need this function mainSocket.onopen = ...

I understand. Based on the above information, I need to make the following points:

  1. Do you really need ssh access to the Raspberry PI using a WebSocket? Please think about it!
  2. You are using the same port, i.e., 8080, for two purposes, which is incorrect. By default, rosbridge_server and ssh runs on 9090 and 22 port, respectively. Please check and correct those port numbers.
  3. Lastly, it seems difficult to make an ssh connection using a WebSocket. Moreover, I do not understand why someone would pick a WebSocket to connect to an ssh server. Please read a similar question asked in StackOverflow for further details.
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-09-20 15:14:53 -0600

Seen: 43 times

Last updated: Sep 23