Skip to main content

hdds-ws

HDDS WebSocket Bridge - Connect browsers to DDS topics in real-time.

Overview

hdds-ws is a lightweight WebSocket server that bridges web applications to the DDS data bus. It enables browsers, dashboards, and any WebSocket client to subscribe to DDS topics and receive live data, as well as publish messages back to the DDS network.

Key Features:

  • Real-time DDS data streaming to web browsers
  • Subscribe/Unsubscribe to any DDS topic
  • Publish messages from web clients to DDS
  • Topic discovery
  • Built-in demo UI
  • ROS 2 std_msgs/String native support
  • JSON-based protocol
  • Automatic reconnection handling

Installation

From Source

cd hdds/tools/hdds-ws
cargo build --release

The binary will be at target/release/hdds-ws.

From Cargo

cargo install hdds-ws

Quick Start

1. Start the WebSocket Bridge

# Default: port 9090, domain 0
hdds-ws

# Custom port and domain
hdds-ws --port 8080 --domain 42

# With debug logging
hdds-ws --log-level debug

2. Open the Demo UI

Navigate to http://localhost:9090/ in your browser to access the built-in demo interface.

3. Connect from JavaScript

const ws = new WebSocket('ws://localhost:9090/ws');

ws.onopen = () => {
console.log('Connected to HDDS');

// Subscribe to a topic
ws.send(JSON.stringify({
type: 'subscribe',
topic: 'temperature'
}));
};

ws.onmessage = (event) => {
const msg = JSON.parse(event.data);

if (msg.type === 'data') {
console.log(`${msg.topic}: ${JSON.stringify(msg.sample)}`);
}
};

CLI Reference

hdds-ws [OPTIONS]

Options:
-p, --port <PORT> WebSocket server port [default: 9090]
-b, --bind <ADDR> Bind address [default: 0.0.0.0]
-d, --domain <ID> DDS Domain ID [default: 0]
--name <NAME> Participant name [default: hdds-ws-bridge]
--log-level <LEVEL> Log level: trace, debug, info, warn, error [default: info]
--max-clients <N> Maximum concurrent connections [default: 100]
-h, --help Print help
-V, --version Print version

Endpoints

EndpointDescription
GET /Built-in demo UI
GET /wsWebSocket connection endpoint
GET /healthHealth check (JSON response)

Health Check Response

{
"status": "ok",
"version": "1.0.0",
"domain": 0,
"clients": 5,
"max_clients": 100
}