WebRTC Best Practices: What You Need to Know About SDP/ICE, WHIP/WHEP, and STUN/TURN
Quick Answer
WebRTC best practices center on three foundational protocol layers. SDP/ICE handles session negotiation, WHIP/WHEP provides HTTP-based signaling, and STUN/TURN manages network traversal. Standards-compliant implementation of all three lets any WebRTC client connect to any WebRTC server without custom code, while configurable STUN/TURN keeps connectivity reliable across NATs and firewalls.

WebRTC has matured from an experimental browser API into a full W3C and IETF standard. Three protocol layers do the heavy lifting in any WebRTC workflow:
- SDP/ICE negotiates what media flows and how endpoints reach each other.
- WHIP/WHEP simplifies publishing and playback signaling over HTTP.
- STUN/TURN discovers network paths and relays media when direct connections fail.
How Do SDP and ICE Work?
SDP (Session Description Protocol) and ICE (Interactive Connectivity Establishment) work together to set up every WebRTC session. SDP defines what media the endpoints will exchange, and ICE determines how they will connect across the network.
What Is SDP?
SDP (Session Description Protocol) is the handshake that establishes the terms of a WebRTC session. One side creates an offer that describes its capabilities, including supported codecs, media types, and encryption parameters, and the other side returns an answer confirming what it accepts. SDP does not transport media itself. It ensures both sides agree on the terms before any audio or video flows.
What Is ICE?
ICE (Interactive Connectivity Establishment) handles the network side of the connection. After both parties agree on the media, ICE gathers candidates, which are possible network paths that include local addresses, server-reflexive addresses discovered through STUN, and relay addresses provided by TURN. ICE then tests those candidates systematically to find the best working route. This process is what makes WebRTC viable across the real-world complexity of NATs, firewalls, and corporate networks.
Why Does Standards Compliance Matter for SDP/ICE?
Standards-compliant SDP/ICE negotiation lets any compliant client connect to any compliant server. Implementations that deviate with proprietary extensions, non-standard SDP attributes, or custom ICE handling introduce fragility. Browsers update their WebRTC stacks frequently, and non-standard implementations tend to break when they do. Teams then spend time patching client code to keep pace with Chrome, Safari, Firefox, and Edge releases instead of building features.
Standards-compliant negotiation removes that maintenance burden. Streams work across all major browsers and native SDKs because every component speaks the same language. There is no proprietary client library, no custom JavaScript SDK, and no vendor lock-in at the signaling layer.
Implementation Tips for SDP/ICE
Production WebRTC deployments benefit from a few practices adopted from the start:
- Use Trickle ICE to cut connection setup time. Trickle ICE starts negotiation immediately and sends candidates as it discovers them, rather than gathering all candidates first. This approach can shave seconds off connection establishment, which matters in real-time applications.
- Test across all major browsers regularly. Standards alignment does not guarantee identical behavior, because each browser carries its own quirks around codec priority, ICE timing, and DTLS handling. Automated cross-browser testing for the signaling flow repays the investment.
- Avoid SDP munging. Manually modifying SDP strings to force codec preferences or bandwidth limits is brittle and breaks when browser SDP formats change. Proper offer/answer semantics and the RTCRtpTransceiver APIs handle codec negotiation more reliably.
Wowza Streaming Engine handles SDP/ICE negotiation per the W3C and IETF specifications, so any standard WebRTC client connects without custom client-side code. That capability matters most for teams managing diverse endpoint environments where mandating a specific SDK is not practical.
What Are WHIP and WHEP?
WHIP and WHEP are HTTP-based signaling protocols that simplify broadcast-style WebRTC workflows. WHIP handles ingest from a publisher, and WHEP handles playback to a viewer, both through a single HTTP request and response rather than a persistent WebSocket connection.
Traditional WebRTC signaling relies on WebSocket connections to exchange SDP offers and answers. WebSockets suit interactive, bidirectional use cases like video conferencing, where ongoing signaling needs a persistent connection. But, for broadcast-style workflows that involve one publisher or one viewer, maintaining a persistent WebSocket connection for a single SDP exchange adds unnecessary overhead.
What Is WHIP?
WHIP (WebRTC-HTTP Ingestion Protocol) provides a simple HTTP-based mechanism for publishing a stream. An encoder sends an SDP offer as an HTTP POST to a WHIP endpoint, and the server returns an SDP answer in the HTTP response body. The signaling exchange completes in a single request and response cycle, with no WebSocket connection and no custom protocol handling.
What Is WHEP?
WHEP (WebRTC-HTTP Egress Protocol) is the playback counterpart to WHIP. A viewer’s client sends an HTTP POST to a WHEP endpoint requesting a stream, receives the SDP answer, and begins playback. WHEP delivers the same simplicity and the same HTTP-native approach for egress.
WHIP vs. WHEP vs. WebSocket Signaling
| Signal | Direction | Transport | Best for |
| WHIP | Ingest (publish) | HTTP POST/response | Broadcast-style one-to-many publishing |
| WHEP | Egress (playback) | HTTP POST/response | Low-latency viewer playback |
| WebSocket | Bidirectional | Persistent socket | Interactive, real-time renegotiation |
Why WHIP/WHEP Matters for Containerized Deployments
HTTP-based signaling aligns naturally with cloud-native architectures. WHIP/WHEP works cleanly with standard load balancers, API gateways, and reverse proxies, which removes the need for sticky sessions or WebSocket-aware routing. Signaling traffic looks like any other HTTP API call, so it fits existing patterns for authentication, rate limiting, logging, and monitoring.
In Kubernetes environments, teams scale, route, and manage WHIP/WHEP signaling with the same tools they use for every other service in the cluster. Because signaling is stateless from the HTTP layer’s perspective, teams distribute WHIP/WHEP endpoints across multiple containers or pods without worrying about connection affinity, which makes horizontal scaling straightforward.
WHIP/WHEP also opens streaming workflows to a growing ecosystem of encoders that support these protocols natively. OBS Studio and FFmpeg both support WHIP, along with a range of hardware encoders, so publishers connect to streaming infrastructure without custom integration work.
Implementation Tips for WHIP/WHEP
- Use WHIP/WHEP for broadcast-style, one-to-many workflows where HTTP signaling simplicity delivers a clear win.
- Reuse existing HTTP infrastructure. WHIP/WHEP endpoints sit behind the same CDN, load balancer, and authentication middleware that protect other APIs, which reduces operational complexity.
- Plan to support both WHIP/WHEP and WebSocket signaling methods so each use case picks the right tool.
Wowza Streaming Engine supports both WHIP/WHEP and WebSocket signaling, which lets teams choose the right approach per use case or run both in the same deployment. For teams running Wowza Streaming Engine in Docker or Kubernetes, the HTTP-based WHIP/WHEP model fits containerized deployment patterns without special accommodations for persistent connections.
How Do STUN and TURN Work?
STUN and TURN solve the network traversal problem that stands between two WebRTC endpoints. Most devices sit behind NATs and firewalls that obscure their true network addresses, which is why both protocols matter. STUN helps a client discover its public address for direct connections, and TURN relays media when direct connections are not possible.
What Is STUN?
STUN (Session Traversal Utilities for NAT) is a lightweight protocol that helps a client discover its public-facing IP address and port mapping. When a WebRTC client queries a STUN server, the server returns the client’s public address as seen from the outside. The client then includes that address as an ICE candidate, which enables direct peer-to-peer connections in many common network configurations. STUN requests stay small, fast, and low-overhead.
What Is TURN?
TURN (Traversal Using Relays around NAT) is the fallback for environments where direct connections fail. Symmetric NATs, strict corporate firewalls, VPN configurations, and air-gapped networks block the paths that STUN alone can establish. TURN servers act as relays that receive media from one peer and forward it to the other. The connection still works, though media passes through the TURN server rather than flowing directly between endpoints.
STUN vs. TURN
| Protocol | Function | Overhead | When it applies |
| STUN | Discovers public address for direct connection | Low | Roughly 80%-85% of network scenarios |
| TURN | Relays media through a server | High | Restrictive networks where direct paths are blocked |
When to Use STUN and When to Use TURN
STUN establishes direct connections in roughly 80%-85% of real-world network scenarios, which makes it the lightweight, low-cost default. The remaining 15%-20% often includes environments where reliable connectivity matters most, such as enterprise offices with strict firewall policies, government networks, healthcare facilities, and remote field deployments.
Production deployments should always configure both STUN and TURN. STUN alone fails silently for a significant minority of users, often the highest-value users in enterprise and regulated environments. TURN guarantees universal connectivity even when direct paths stay blocked.
Implementation Tips for STUN/TURN
- Start with public STUN servers for development and testing. Public STUN servers work reliably for non-production scenarios. Production deployments should run dedicated STUN/TURN infrastructure or use a trusted provider.
- Size TURN servers carefully. TURN relays all media traffic for connections that require it, so bandwidth scales directly with the number of relayed sessions and their bitrates. A single 1080p stream relayed through TURN can consume 2-4 Mbps of server bandwidth in each direction.
- Use short-lived TURN credentials. Static credentials create a security exposure, because anyone holding them can use the relay infrastructure. Time-limited tokens that stay valid for hours rather than days ensure that leaked credentials expire quickly.
For enterprise and government deployments, the ability to deploy TURN servers inside the network perimeter is often a hard requirement. Air-gapped environments, classified networks, and organizations with strict data sovereignty rules need media relay infrastructure that never routes traffic through external servers.
Wowza Streaming Engine ships pre-configured with public STUN servers for out-of-the-box functionality and supports full custom STUN/TURN configuration for enterprise deployments. Teams can point Wowza Streaming Engine at private STUN/TURN infrastructure to meet the network traversal requirements of a corporate campus, a government facility, or a globally distributed cloud deployment.
What Does A Production WebRTC Architecture Look Like?
A production WebRTC architecture connects SDP/ICE, WHIP/WHEP, and STUN/TURN into a single workflow. An encoder publishes a live stream using WHIP, which initiates an SDP/ICE negotiation over HTTP. ICE gathers candidates through the configured STUN/TURN servers and establishes a connection. The media server then receives the WebRTC ingest, and the delivery options expand from there.
Viewers can consume the stream in real time through WHEP for sub-second latency, or the server can transcode and deliver over HLS, DASH, or LL-HLS for scaled distribution to larger audiences. RTMP gets used for syndication, RTSP is common in IP cameras, and SRT is used for point-to-point delivery. A single ingest supports multiple delivery paths.
This multi-protocol flexibility is where a media server earns its place in the architecture. WebRTC is peer-to-peer by design and does not inherently scale to large audiences. A server-mediated model accepts WebRTC ingest and fans out delivery across whatever protocols the audience requires, which matches the right delivery method to each viewer’s latency and compatibility needs.
Codec Considerations
H.264 remains the safest cross-browser and cross-device codec choice for WebRTC. H.265, also called High Efficiency Video Coding (HEVC), delivers roughly 50% better compression than H.264 at equivalent quality, which makes it attractive for 4K and high-bitrate sources like IP cameras and broadcast encoders. But, browser support for H.265 in WebRTC arrived somewhat recently and remains uneven across the ecosystem. The codec selection below balances compatibility against efficiency.
| Codec | Browser support | Notes |
| H.264 | Universal | Hardware-accelerated on nearly every platform |
| H.265/HEVC | Partial (Chrome 136+, Safari 18+) | Hardware-dependent encode and decode, absent in Firefox and Edge |
| VP8 / VP9 | Broad | Royalty-free alternatives with good support |
| AV1 | Emerging | High efficiency, though hardware support is still maturing |
Teams should negotiate codecs through SDP rather than relying on SDP munging, which keeps the implementation clean and maintainable as codec support evolves.
Monitoring and Debugging
Chrome’s built-in WebRTC internals, available at chrome://webrtc-internals, provide detailed statistics on ICE candidate gathering, connection state transitions, codec negotiation results, and media quality metrics. Logging SDP exchanges during development helps diagnose negotiation failures quickly, and monitoring ICE connection state changes in production surfaces connectivity issues before they reach viewers.
Move Forward With Standards-Compliant WebRTC
SDP/ICE handles signaling, WHIP/WHEP simplifies HTTP-based workflows, and STUN/TURN manages network traversal. Building on these standards means streaming infrastructure evolves with the ecosystem rather than against it. Browser updates strengthen an implementation rather than threaten it, new encoders and clients work out of the box, and teams spend time building features rather than maintaining compatibility.
Wowza Streaming Engine brings these standards together within an enterprise-grade platform, which gives teams the tools to run WebRTC workflows flexibly and confidently from ingest through delivery, across any deployment environment. Contact a Wowza streaming expert for a demo.
WebRTC Frequently Asked Questions
What is the latency of WebRTC?
WebRTC delivers ultra-low latency, typically under 500 milliseconds, and often sub-second end to end. That performance makes WebRTC the preferred protocol for interactive use cases such as live auctions, betting platforms, two-way communication, and remote operation, where delays must stay minimal.
What is the difference between WHIP and WHEP?
WHIP and WHEP are complementary HTTP-based WebRTC signaling protocols. WHIP (WebRTC-HTTP Ingestion Protocol) handles ingest by letting an encoder publish a stream through an HTTP POST, while WHEP (WebRTC-HTTP Egress Protocol) handles playback by letting a viewer request a stream the same way. Both complete signaling in a single request and response cycle.
Do I need both STUN and TURN for WebRTC?
Production WebRTC deployments should configure both STUN and TURN. STUN establishes direct connections in roughly 80 to 85 percent of network scenarios at low cost, and TURN relays media in the remaining 15 to 20 percent where firewalls or symmetric NATs block direct paths. Configuring only STUN causes silent connection failures for users in restrictive enterprise and government networks.
What is SDP munging and why should teams avoid it?
SDP munging is the practice of manually editing SDP strings to force codec preferences or bandwidth limits. Teams should avoid SDP munging because it is brittle and breaks when browser SDP formats change. Proper offer/answer semantics and the RTCRtpTransceiver APIs handle codec negotiation more reliably.
Which codec is best for WebRTC?
H.264 is the safest codec choice for WebRTC because it is hardware-accelerated and universally supported across browsers and devices. VP8 and VP9 offer royalty-free alternatives with broad support, while H.265 and AV1 provide higher efficiency (though hardware support is still maturing).
Does WebRTC support H.265 (HEVC)?
WebRTC supports H.265 in Chrome version 136 and later and in Safari version 18.0 and later, on devices with hardware encode or decode available. Firefox and Edge do not support H.265 over WebRTC. Because support remains uneven, deployments targeting broad browser audiences should configure H.264 as a fallback codec.
Can WebRTC scale to large audiences?
WebRTC does not scale to large audiences on its own, because the protocol is peer-to-peer by design. A media server solves this by accepting WebRTC ingest and transcoding it for delivery over scalable protocols such as HLS, DASH, LL-HLS, RTMP, RTSP, or SRT, which lets a single ingest reach audiences of any size.
Does WebRTC work in containerized and Kubernetes deployments?
WebRTC works well in containerized and Kubernetes deployments, particularly when it uses WHIP/WHEP for signaling. HTTP-based signaling integrates with standard load balancers, ingress controllers, and service meshes without sticky sessions, and STUN/TURN settings can be managed through environment variables or configuration maps.
Does Wowza Streaming Engine require a proprietary WebRTC client?
Wowza Streaming Engine does not require a proprietary WebRTC client. WSE handles SDP/ICE negotiation per the W3C and IETF specifications, so any standards-compliant browser or native application connects directly without a vendor-specific SDK or custom JavaScript library.
