A WebRTC HTTP Ingest Protocol (WHIP) and WebRTC HTTP Egress Protocol (WHEP) server implementation specifically designed for VDO.Ninja integration.
- Enable self-hosting of WHIP/WHEP services for VDO.Ninja
- Provide a spec-compliant WHIP/WHEP endpoint (Work in Progress)
- Allow VDO.Ninja users to replace Meshcast.io with their own WHIP/WHEP service
- Future integration support for popular SFU servers (Cloudflare/PION)
- This is NOT an SFU server
- Requires an active viewer connected before WHIP streaming can begin
- Some WHIP publishers may have limited NAT traversal support
- Written in Node.js for accessibility and cloud worker compatibility
- The official service runs at whip.vdo.ninja
- Node.js (https://nodejs.org/)
- npm or yarn package manager
- SSL certificate (for production) or self-signed cert (for testing)
- Domain name (recommended for production SSL)
# Clone the repository
git clone [repository-url]
cd whip-server
# Install dependencies
npm install express ws node-fetchFor testing/offline use, generate a self-signed certificate:
openssl req -nodes -new -x509 -keyout key.pem -out cert.pemFor production, use Let's Encrypt/Certbot or your preferred SSL provider.
Server configuration is optional, as the defaults will work for most people.
- Environment variables:
Configure the ENV variables using any of these methods:
# Temporary (current session)
export KEY_PATH=/path/to/ssl/key.pem
export CERT_PATH=/path/to/ssl/cert.pem
export PORT=8443
# Permanent (user)
echo 'export KEY_PATH=/path/to/ssl/key.pem' >> ~/.bashrc
echo 'export CERT_PATH=/path/to/ssl/cert.pem' >> ~/.bashrc
echo 'export PORT=8443' >> ~/.bashrc
source ~/.bashrc
# System-wide
sudo echo 'KEY_PATH=/path/to/ssl/key.pem
CERT_PATH=/path/to/ssl/cert.pem
PORT=8443' > /etc/environment.d/myapp.confCheck that the value took with: echo $KEY_PATH
- ICE Servers: Edit the iceServers array in server.js to configure your STUN/TURN servers:
const iceServers = [
'stun:stun.l.google.com:19302; rel="ice-server"',
'stun:stun.cloudflare.com:3478; rel="ice-server"',
'turn:your.turn.server:3478; rel="ice-server"; username="user"; credential="pass"'
];Development:
node whip.jsProduction (using PM2):
npm install -g pm2
pm2 start whip.js
pm2 saveIf using this with a self-hosted VDO.Ninja, you'll likely be wanting to specify the WHIP address to match you own.
In the index.html file, contained in the root of the VDO.Ninja folder, edit the following line:
// session.whipServerURL = "wss://whip.vdo.ninja"; // If you deploy your own whip websocket service
Uncomment it and change the websocket address to match whatever you are using. eg: session.whipServerURL = "ws://127.0.0.1:8443";.
If having problems, double check you have your SSL certs configured correctly, etc.
- The server implements a 1MB message size limit for WebSocket connections
- SSL is required for WebRTC in production environments
- CORS headers are preconfigured but may need adjustment
- Custom TURN servers are required for production use
- Authentication is implemented via Bearer tokens or URL parameters
To use with a self-hosted VDO.Ninja instance, update your VDO.Ninja configuration to point to your WHIP server instead of whip.vdo.ninja.
- Requires active viewer connection for WHIP publishing
- NAT traversal depends on proper STUN/TURN configuration
- SSL setup is required but not handled by this package
- Limited deployment support available
- Code issues & feature requests: Create a GitHub issue
- General support: Join the Discord server (discord.vdo.ninja)
- SSL/TURN setup: Outside current support scope
PRs welcome! Please contribute fixes and improvements 💘
MIT License - Copyright (c) 2024 VDO.Ninja