eProsima/Integration-Service

websocket-server not publishing topic

Closed this issue · 2 comments

I am trying to set up a soss-server to connect ROS2 <-> websocket.

As it concerns a custom message type (xxxx_interfaces/MyData) I have generated the .mix files by adding the appropriate generator call in the ros2-test package (am I correct that this is not necessary for the websocket package as it will talk plain json)?

I have modified the websocket example to be:

systems:
  ws_server:  { type: websocket_server, port: 12345, cert: ../Host.cert,    key: ../Host.key },
  ros2_node: { type: ros2 }

routes:
  ros_to_ws: { from: ros2_node, to: ws_server }

topics:
  MyTopic: { type: "xxxx_interfaces/MyData", route: ros_to_ws }

I start my soss websocket-server with
soss example/sample-websocket-server-config.yaml
and I indeed see a new subscriber to MyTopic in ROS2.

I also can connect to the websocket server using a browser based test client and there I recieve a single advertise message:
{"op":"advertise","topic":"MyTopic","type":"xxxx_interfaces/MyData"}

MyTopic is constantly publishing messages, but I only see that one message arrive on the websocket. I would assume I should see a stream of MyTopic messages in my websocket client. I'm stuck at this point.

Any ideas on what might be happening?

Keep in mind that the websocket server is using the websocket rosbridge protocol so you'll need to have your websocket client explicitly subscribe to the topic that you care about after connecting to the server.

The advertisement message is to let your client know what topics are available for it to subscribe to, but no further messages will come until the client subscribes.

I was unfamiliar with the websocket rosbridge protocol.

I succesfully subscribed to a event by sending to the server:

{ "op": "subscribe", "topic": "MyTopic" }

and the messages started flowing in. Thanks for the quick reply!