RTSP over WebSocket is an advanced technology that encapsulates traditional RTSP signaling and media data within WebSocket frames. It perfectly solves the problems of firewall/NAT traversal, port restrictions, and complex network environments that arise when using native RTSP in web frontends, mobile apps, and modern networks. HappyTime RTSP Server and HappyTime RTSP Client provide native, efficient support for RTSP over WebSocket, making real-time video stream integration easier than ever. This article covers the principles, server configuration, and step-by-step instructions for testing RTSP over WebSocket (ws://) as well as its encrypted version (wss://).
1. Introduction to RTSP over WebSocket
Traditional RTSP runs over TCP/UDP, typically using port 554, which is often blocked by firewalls in enterprise networks, cloud environments, and web applications. WebSocket, on the other hand, is built on top of HTTP/HTTPS (default ports 80/443), traverses most proxies and firewalls, and provides full-duplex, low-latency communication channels. RTSP over WebSocket encapsulates RTSP requests/responses and RTP/RTCP data inside WebSocket frames, delivering:
- Seamless traversal: Uses HTTP(S) ports, no additional firewall rules required.
- Low-latency real-time performance: Full-duplex communication avoids HTTP polling overhead, ideal for video surveillance, drones, live streaming, etc.
- Unified session management: A single WebSocket connection carries both RTSP control and media streams, simplifying connection handling.
- Enhanced security: wss:// (WebSocket over TLS/SSL) provides encrypted transmission, protecting sensitive video streams.
HappyTime RTSP Server merges RTSP over WebSocket with RTSP over HTTP, using the same HTTP/HTTPS ports with flexible configuration and low resource usage. On the client side, simply change the RTSP URL prefix to ws:// or wss://
for a quick migration.
• If the RTSP URL starts with
ws://, RTSP over WebSocket connection is used
automatically.• If it starts with
wss://, it uses TLS/SSL secured WebSocket (RTSP over WebSocket Secure).• The traditional
rtsp:// prefix keeps the native RTSP protocol. 2. Server-Side Configuration: Enable RTSP over WebSocket
HappyTime RTSP Server manages RTSP over WebSocket together with RTSP over HTTP, using the same switch and ports. You only need to enable rtsp_over_http in the server configuration file and set the HTTP port; WebSocket support is automatically activated. Below
is a typical configuration snippet:
<!-- Enable RTSP over HTTP/WebSocket, 0-disable,1-enable -->
<rtsp_over_http>1</rtsp_over_http>
<!-- HTTP/WebSocket service port (RTSP over WebSocket uses this port) -->
<http_port>80</http_port>
<!-- Enable TLS-based secure transport (supports both HTTPS and WSS) -->
<rtsp_over_https>1</rtsp_over_https>
<!-- HTTPS / WSS service port -->
<https_port>8443</https_port>
After applying the configuration, restart the RTSP server. The server will then offer both RTSP over HTTP and RTSP over WebSocket capabilities on http_port (e.g., 80) and https_port (e.g., 8443). Clients can connect using
ws://serverIP:80/rtsp/stream_name or wss://serverIP:8443/rtsp/stream_name to establish a WebSocket tunnel.
3. How to Test RTSP over WebSocket Using HappyTime RTSP Client
This section demonstrates two typical scenarios: non-encrypted WebSocket (ws://) and encrypted WebSocket (wss://) with a complete testing workflow.
Open Happytime RTSP Client application.
Click the play button in the video window. Enter the stream address using the following format: ws://[server_address]:[http_port]/[stream_path]. For example:
ws://192.168.1.100:80/live/stream
Where:
- 192.168.1.100 is your RTSP server IP.
- 80 matches the http_port in the configuration.
- /live/stream is the published RTSP stream name on the server (adjust as needed).
Click the "OK"
button. The client will automatically send RTSP commands (OPTIONS, DESCRIBE, SETUP, PLAY, etc.) over WebSocket and receive RTP/RTCP data. If everything works, the video appears instantly.
For encrypted transmission scenarios, ensure the server has enabled rtsp_over_https and a valid certificate (self-signed or CA). HappyTime RTSP Client supports ignoring certificate errors for testing. The URL format is:
wss://192.168.1.100:8443/live/stream
The port should be the https_port (8443 in the example). Once successfully connected, all RTSP interactions and video data are transmitted via a TLS-encrypted WebSocket channel, ensuring privacy.
4. Advantages of RTSP over WebSocket Compared to Traditional RTSP/HTTP
Compared to native RTSP over TCP/UDP, RTSP over WebSocket shows clear benefits in web environments and large-scale distributed systems. The table below summarizes the differences:
| Feature | Native RTSP | RTSP over HTTP | RTSP over WebSocket |
|---|---|---|---|
| Firewall traversal | Difficult (port 554 often blocked) | Good (80/443) | Excellent (80/443, full duplex) |
| Real-time / Latency | Very low | Moderate (request-response) | Low latency (full duplex) |
| Native browser support | Not supported | Requires plugin | Supported (JavaScript WebSocket API) |
| Header overhead | Low | High | Low (small frame headers) |
| Encryption support | RTSP over TLS | HTTPS tunnel | WSS (standard TLS) |
The seamless integration of HappyTime RTSP Server and Client lets you enjoy all the benefits of RTSP over WebSocket effortlessly.
5. Conclusion
With this article, you have learned the complete workflow from theory to practice for testing RTSP over WebSocket. Using the built-in support of HappyTime RTSP Server, you only need to configure a few ports and switches, then pair it with HappyTime RTSP Client to quickly verify ws:// and wss:// connections. Whether you are developing embedded devices, building a no-plugin web surveillance system, or deploying a low-latency streaming platform, RTSP over WebSocket is the ideal choice for modern video integration.