Skip to content

Commit 85d1a50

Browse files
committed
Local signaling server
1 parent ea8129a commit 85d1a50

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,19 @@ sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
3535

3636
Finally, ROS is required. ROS 1 and ROS 2 are both supported. For ROS1, install Noetic as per [these installation instructions](https://wiki.ros.org/noetic/Installation/Ubuntu). For ROS2, we recommend using Kilted as the latest release ([installation instructions](https://docs.ros.org/en/kilted/Installation/Ubuntu-Install-Debs.html)), but earlier distros should also work.
3737

38-
In addition to base ROS, a websocket bridge server is required for ROS 2 only:
38+
For ROS1: set the flag in `src/commands/start.rs` line 20.
39+
40+
```rust
41+
const ROS1: bool = false;
42+
```
43+
44+
For ROS2: a websocket bridge server is additionally required:
3945

4046
```bash
4147
sudo apt install ros-$ROS_DISTRO-rosbridge-suite
4248
```
4349

50+
4451
Build the package as follows:
4552

4653
```bash

scripts/signaling_server.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33

44
clients = {}
5+
local = True
6+
7+
# # TLS configuration
8+
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
9+
ssl_context.load_cert_chain("certs/dev-server.crt", "certs/dev-server.key")
10+
11+
if local:
12+
ssl_context = None
513

614
async def handler(ws):
715
print("Waiting for connections. Connected clients: {}".format(clients))
@@ -27,11 +35,7 @@ async def main():
2735
local_ip = "0.0.0.0"
2836
port = 8765
2937

30-
# TLS configuration
31-
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
32-
ssl_context.load_cert_chain("certs/dev-server.crt", "certs/dev-server.key")
33-
34-
print(f"Starting secure WebSocket server at wss://{local_ip}:{port}")
38+
print(f"Starting secure WebSocket server at ws://{local_ip}:{port}")
3539
async with websockets.serve(handler, local_ip, port, ssl=ssl_context):
3640
await asyncio.Future()
3741

scripts/test_signaling_server.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
import asyncio
2-
import websockets
3-
import json
4-
import ssl
1+
import asyncio, websockets, json, ssl
52

63
SERVER_HOST = "localhost"
74
SERVER_PORT = 8765
8-
URI = f"wss://{SERVER_HOST}:{SERVER_PORT}"
5+
URI = f"ws://{SERVER_HOST}:{SERVER_PORT}"
96

107
# SSL context (use self-signed cert)
118
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
129
ssl_context.check_hostname = False # Skip hostname verification (for self-signed)
1310
ssl_context.verify_mode = ssl.CERT_NONE # Skip certificate verification (for testing)
1411

1512
async def test_client():
16-
print(f"Connecting to wss://{SERVER_HOST}:{SERVER_PORT}...")
13+
print(f"Connecting to {URI}...")
1714

1815
try:
1916
async with websockets.connect(

0 commit comments

Comments
 (0)