Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pion/webrtc/llms.txt
Use this file to discover all available pages before exploring further.
Overview
AConfiguration defines how peer-to-peer communication via PeerConnection is established or re-established. Configurations may be set up once and reused across multiple connections.
Source:
configuration.go:9-59Configurations are treated as readonly. As long as they are unmodified, they are safe for concurrent use.
Type Definition
Fields
ICEServers
Defines a slice describing servers available to be used by ICE, such as STUN and TURN servers.
Source:
configuration.go:15-17ICETransportPolicy
Indicates which candidates the ICEAgent is allowed to use.
Source:
configuration.go:19-21ICETransportPolicyAll(default) - All candidates may be usedICETransportPolicyRelay- Only relay candidates (TURN) may be used
BundlePolicy
Indicates which media-bundling policy to use when gathering ICE candidates.
Source:
configuration.go:23-25BundlePolicyBalanced(default)BundlePolicyMaxBundle- Bundle all media on a single transportBundlePolicyMaxCompat- Use separate transports for each media type
RTCPMuxPolicy
Indicates which RTCP-mux policy to use when gathering ICE candidates.
Source:
configuration.go:27-29RTCPMuxPolicyRequire(default) - Only gather RTCP candidates for multiplexed RTCPRTCPMuxPolicyNegotiate- Gather ICE candidates for both RTP and RTCP
Modern WebRTC implementations typically use
RTCPMuxPolicyRequire to multiplex RTP and RTCP on the same port.PeerIdentity
Sets the target peer identity for the PeerConnection. The PeerConnection will not establish a connection to a remote peer unless it can be successfully authenticated with the provided name.
Source:
configuration.go:31-34Certificates
Describes a set of certificates that the PeerConnection uses to authenticate.
Source:
configuration.go:36-47GenerateCertificate function. If this value is absent, a default set of certificates is generated for each PeerConnection instance.
ICECandidatePoolSize
Describes the size of the prefetched ICE pool.
Source:
configuration.go:49-50CreateOffer() or CreateAnswer().
Currently, pool sizes greater than 1 are not supported and will result in an error.
SDPSemantics
Controls the type of SDP offers accepted by and SDP answers generated by the PeerConnection.
Source:
configuration.go:52-54SDPSemanticsUnifiedPlan(default) - Modern standardSDPSemanticsPlanB- Legacy Google Plan BSDPSemanticsUnifiedPlanWithFallback- Try Unified Plan, fall back to Plan B
AlwaysNegotiateDataChannels
Specifies whether the application prefers to always negotiate data channels in the initial SDP offer.
Source:
configuration.go:56-58When set to true, a data channel section will be included in the SDP even if no data channels have been created yet.
Usage Examples
Basic Configuration
Basic Configuration
Minimal configuration with a public STUN server:
With TURN Server
With TURN Server
Configuration including TURN for relay:
Relay-Only Configuration
Relay-Only Configuration
Force all traffic through TURN (no direct connections):
Complete Configuration
Complete Configuration
Full configuration with all options:
Modifying Configuration
After creating a PeerConnection, you can update certain configuration properties:Best Practices
Use STUN for Discovery
Always include at least one STUN server to discover your public IP address for NAT traversal.
Include TURN for Reliability
Add a TURN server for scenarios where direct connections fail (strict firewalls, symmetric NATs).
Reuse Configurations
Create one configuration and reuse it across multiple PeerConnections to save resources.
Test Relay-Only
Test with
ICETransportPolicyRelay to verify your TURN server works before production.Common Patterns
Environment-Based Configuration
Configuration Validation
See Also
- PeerConnection - Using Configuration with PeerConnection
- API - API-level configuration
- ICE Servers - Setting up STUN/TURN servers