A peer-to-peer video calling application built using WebRTC, WebSockets, and Flask. This project demonstrates real-time communication protocols and network programming concepts.
Project Submission for Networking Lab
- Features
- Architecture
- Prerequisites
- Installation
- Running the Application
- Usage
- Project Structure
- Technical Details
- Troubleshooting
- Team Members
- Peer-to-Peer Video Calling: Direct WebRTC connections between clients
- Secure Communication: HTTPS and WSS (WebSocket Secure) implementation
- Mobile-Friendly: Responsive web interface that works on phones and tablets
- Room-Based System: Multiple concurrent calls in different rooms
- Real-Time Controls: Toggle camera/microphone during calls
- Cross-Platform: Works on Windows, Linux, and macOS
- Self-Signed SSL: Automated certificate generation for local network deployment
-
Signaling Server (
signaling_server_ssl.py)- WebSocket server for peer discovery and signaling
- Handles room management and peer connection coordination
- Implements secure WebSocket (WSS) protocol
-
Web Server (
web_server.py)- Flask-based HTTPS server
- Serves the web interface
- Provides landing page and call interface
-
Web Client (HTML/JavaScript)
- WebRTC implementation in browser
- Handles media streams and peer connections
- Responsive UI with real-time status updates
-
Certificate Generator (
generate_cert.py)- Creates self-signed SSL certificates
- Configures certificates for local network use
- Python: 3.8 or higher
- Operating System: Windows 10/11, Linux, or macOS
- Network: Both devices must be on the same local network (same WiFi)
- Browser: Modern browser with WebRTC support
- Chrome/Edge: Version 80+
- Firefox: Version 75+
- Safari: Version 14+
cd /path/to/your/project
pip install -r requirements.txt
Alternative (if using virtual environment):
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
python generate_cert.py
Output:
Generating certificate for: 192.168.1.100
β
Certificate generated successfully!
π Files created in 'certs' folder:
- cert.pem
- key.pem
π Your local IP: 192.168.1.100
π± Use this URL on your phone: https://192.168.1.100:8443
Note: Save the IP address shown - you'll need it to connect from other devices.
Open a terminal/command prompt and run:
python signaling_server_ssl.py
Expected Output:
======================================================================
π Secure Signaling Server (WSS) Started
======================================================================
Local: wss://localhost:8765
Phone: wss://192.168.1.100:8765
======================================================================
Keep this terminal open.
Open a second terminal/command prompt and run:
python web_server.py
Expected Output:
======================================================================
π HTTPS Web Interface Available At:
======================================================================
On this PC: https://localhost:8443
On your phone: https://192.168.1.100:8443
======================================================================
β οΈ IMPORTANT: You'll see a security warning - this is normal!
Click 'Advanced' β 'Accept Risk and Continue' (Firefox)
or 'Advanced' β 'Proceed to site' (Chrome)
Keep this terminal open.
- Open browser and navigate to:
https://localhost:8443 - Accept certificate warning:
- Click "Advanced"
- Click "Accept the Risk and Continue" or "Proceed to localhost"
- Accept signaling server certificate:
- Open new tab:
https://localhost:8765 - Accept certificate warning (you'll see an error page - this is normal)
- Open new tab:
- Return to application tab
- Enter room details:
- Room ID:
room1 - Signaling Server:
wss://localhost:8765
- Room ID:
- Click "Join Call"
- Allow camera/microphone access when prompted
-
Find your PC's IP address (shown when servers started, e.g.,
192.168.1.100) -
On your phone/tablet, open browser and navigate to:
https://YOUR_IP:8443- Example:
https://192.168.1.100:8443
- Example:
-
Accept certificate warnings:
- Main page: Accept certificate
- Signaling server: Visit
https://YOUR_IP:8765in new tab, accept certificate
-
Enter room details:
- Room ID:
room1(same as other device!) - Signaling Server:
wss://YOUR_IP:8765 - Example:
wss://192.168.1.100:8765
- Room ID:
-
Click "Join Call"
-
Allow camera/microphone permissions
-
Both devices should now be connected!
- π€ Microphone Button: Toggle audio on/off
- πΉ Camera Button: Toggle video on/off
- π Hang Up Button: End call and return to home screen
webrtc-video-call/
βββ generate_cert.py # SSL certificate generator
βββ signaling_server_ssl.py # WebSocket signaling server
βββ web_server.py # Flask web server
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ certs/ # Generated SSL certificates
β βββ cert.pem
β βββ key.pem
βββ templates/ # HTML templates
βββ index.html # Landing page
βββ call.html # Video call interface
-
HTTPS (HyperText Transfer Protocol Secure)
- Port: 8443
- Used for serving web interface
- TLS/SSL encryption
-
WSS (WebSocket Secure)
- Port: 8765
- Used for signaling between peers
- Full-duplex communication channel
-
WebRTC (Web Real-Time Communication)
- Peer-to-peer video/audio streaming
- ICE (Interactive Connectivity Establishment)
- STUN servers for NAT traversal
- SDP (Session Description Protocol) for negotiation
- Client-Server Architecture: Signaling server coordinates peer connections
- Peer-to-Peer Communication: Direct media streams between clients
- NAT Traversal: ICE candidates and STUN servers
- Secure Communication: SSL/TLS encryption
- WebSocket Protocol: Real-time bidirectional communication
- Port Forwarding: Firewall configuration
- Local Network Discovery: IP-based addressing
-
Signaling Phase:
- Clients connect to signaling server via WebSocket
- Exchange SDP offers/answers
- Exchange ICE candidates
-
Connection Phase:
- STUN servers help discover public IP addresses
- ICE framework establishes optimal connection path
- Peer connection established
-
Media Phase:
- Video/audio streams transmitted directly between peers
- No server involvement after connection established
- Self-Signed Certificates: Generated locally for HTTPS/WSS
- Certificate Pinning: Browser validates certificate
- Encrypted Signaling: All signaling messages encrypted via WSS
- Encrypted Media: WebRTC uses DTLS-SRTP for media encryption
- Room-Based Isolation: Users can only connect within same room
Solution:
- Verify both servers are running (check terminals)
- Check firewall settings
- Ensure devices are on same WiFi network
- Verify IP address is correct
Solution:
- Must use HTTPS (not HTTP)
- Accept certificate warning on both:
- Main page:
https://YOUR_IP:8443 - Signaling server:
https://YOUR_IP:8765
- Main page:
- Clear browser cache and try again
- Check browser permissions settings
Solution:
- This is normal for self-signed certificates
- Click "Advanced" β "Proceed" or "Accept Risk"
- Must accept for both web page and signaling server
Solution:
- Current implementation supports 2 peers per room
- Use different room name or wait for other peer to leave
Solution:
- Check browser console for errors (F12)
- Verify signaling server shows both clients joining
- Check ICE candidate exchange in console
- Try using same room name on both devices
Solution:
- Phone must use HTTPS URL (
https://nothttp://) - Signaling must use WSS (
wss://notws://) - Accept certificates on phone browser
- Grant camera/microphone permissions
- WebRTC Official Documentation
- MDN Web Docs - WebRTC API
- RFC 8831 - WebRTC Data Channels
- RFC 8866 - SDP: Session Description Protocol
- Flask Documentation
- websockets Library
- Sachithanand S - 24BCE5125
- SiddharthΒ E - 24BCE1261
- Kalyan RamΒ Ch - 24BCE5195
Through this project, we demonstrated understanding of:
- Network Programming: Socket programming, server-client architecture
- Web Protocols: HTTP/HTTPS, WebSocket/WSS
- Real-Time Communication: WebRTC, peer-to-peer connections
- Security: SSL/TLS certificates, encrypted communication
- NAT Traversal: ICE, STUN, and network discovery
- Web Development: HTML5, JavaScript, Flask framework
- System Administration: Firewall configuration, port management