Reorganize the SRS (Simple Realtime Server) repository to follow a conventional Go project structure, setting the stage for a progressive transition from a C++ project to a Go project. The proxy, which was once contained within its own `proxy/` subdirectory, will now be converted into the initial Go module located at the root of the repository, serving as a template for subsequent Go modules. - **Go module at repo root:** `go.mod` moved to repo root, module renamed from `proxy` to `srsx`. The repo is now a proper Go project with `cmd/` and `internal/` at the top level. - **Elevation of Proxy Code:** Move the proxy code from `proxy/cmd/proxy-go/` to `cmd/proxy/`, and from `proxy/internal/` to `internal/`. The proxy serves as the inaugural application; subsequent modules (for instance, `cmd/origin`) will mimic this arrangement. - **Documentation Restructured:** Transfer the documentation from `proxy/docs/` to `docs/proxy/`, revise the main README to endorse OpenClaw as the preferred AI tool, and update `proxy/README.md` to point to the new documentation locations. - **Build and config:** `Makefile` moved to root, `PROXY_STATIC_FILES` default path corrected for the new layout, `.gitignore` consolidated. - **Cleanup:** removed standalone `proxy/LICENSE` (repo-level license applies), all internal imports updated to `srsx/internal/...`. - **OpenClaw workspace:** added community bot info, git workflow conventions, and support group behavior guidance. This restructuring was performed by OpenClaw orchestrating Claude Code and Codex via ACP. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
4.9 KiB
Protocol
Backend Server Registration
The origin server can register itself to the proxy server, so the proxy server can load balance the backend servers.
Default Backend Server (For Debugging)
The proxy can automatically register a default backend server for testing and debugging purposes, controlled by environment variables:
# Enable default backend server
PROXY_DEFAULT_BACKEND_ENABLED=on
# Default backend server configuration
PROXY_DEFAULT_BACKEND_IP=127.0.0.1
PROXY_DEFAULT_BACKEND_RTMP=1935
PROXY_DEFAULT_BACKEND_HTTP=8080 # Optional
PROXY_DEFAULT_BACKEND_API=1985 # Optional
PROXY_DEFAULT_BACKEND_RTC=8000 # Optional (UDP)
PROXY_DEFAULT_BACKEND_SRT=10080 # Optional (UDP)
When enabled, the proxy automatically registers this default backend server at startup and sends heartbeats every 30 seconds to keep it alive. This is useful for:
- Quick testing without setting up backend server registration
- Development and debugging scenarios
- Single-server deployments
Automatic Registration
SRS 5.0+ has built-in support for automatic registration to the proxy server using the heartbeat feature. Configure SRS to send heartbeats to the proxy's System API:
# For example, conf/origin1-for-proxy.conf in SRS.
heartbeat {
enabled on;
interval 9;
url http://127.0.0.1:12025/api/v1/srs/register;
device_id origin1;
ports on;
}
When heartbeat is enabled:
- SRS automatically registers itself on startup
- Sends periodic heartbeats (default: every 30 seconds) to keep the registration alive
- Proxy marks servers as unavailable if heartbeats stop (after 300 seconds)
- No manual intervention required - fully automatic
This is the recommended approach for production deployments with SRS backend servers.
Manual Registration API
For non-SRS backend servers or custom integrations, use the HTTP API directly:
curl -X POST http://127.0.0.1:12025/api/v1/srs/register \
-H "Connection: Close" \
-H "Content-Type: application/json" \
-H "User-Agent: curl" \
-d '{
"device_id": "origin2",
"ip": "10.78.122.184",
"server": "vid-46p14mm",
"service": "z2s3w865",
"pid": "42583",
"rtmp": ["19352"],
"http": ["8082"],
"api": ["19853"],
"srt": ["10082"],
"rtc": ["udp://0.0.0.0:8001"]
}'
#{"code":0,"pid":"53783"}
Registration Fields
ip: Mandatory, the IP of the backend server. Make sure the proxy server can access the backend server via this IP.server: Mandatory, the server id of backend server. For SRS, it stores in file, may not change.service: Mandatory, the service id of backend server. For SRS, it always changes when restarted.pid: Mandatory, the process id of backend server. Used to identify whether process restarted.rtmp: Mandatory, the RTMP listen endpoints of backend server. Proxy server will connect backend server via this port for RTMP protocol.http: Optional, the HTTP listen endpoints of backend server. Proxy server will connect backend server via this port for HTTP-FLV or HTTP-TS protocol.api: Optional, the HTTP API listen endpoints of backend server. Proxy server will connect backend server via this port for HTTP-API, such as WHIP and WHEP.srt: Optional, the SRT listen endpoints of backend server. Proxy server will connect backend server via this port for SRT protocol.rtc: Optional, the WebRTC listen endpoints of backend server. Proxy server will connect backend server via this port for WebRTC protocol.device_id: Optional, the device id of backend server. Used as a label for the backend server.
Listen Endpoint Format
The listen endpoint format is port, or protocol://ip:port, or protocol://:port, for example:
1935: Listen on port 1935 and any IP for TCP protocol.tcp://:1935: Listen on port 1935 and any IP for TCP protocol.tcp://0.0.0.0:1935: Listen on port 1935 and any IP for TCP protocol.tcp://192.168.3.10:1935: Listen on port 1935 and specified IP for TCP protocol.
Integration Options Summary
There are three ways to register backend servers to the proxy:
-
Automatic Registration (Recommended for Production)
- Use SRS 5.0+ with heartbeat feature
- Fully automatic, no manual scripts needed
- Self-healing: automatically re-registers if proxy restarts
- See "Automatic Registration (SRS 5.0+ Heartbeat)" section above
-
Manual Registration API
- For non-SRS media servers (nginx-rtmp, Node-Media-Server, etc.)
- Requires custom registration script or service
- More flexible for heterogeneous environments
- See "Manual Registration API" section above
-
Default Backend (Development/Testing Only)
- Quick setup via environment variables
- No backend server configuration needed
- Use for development, testing, and debugging
- See "Default Backend Server (For Debugging)" section above