Skip to main content

Overview

The SettingEngine allows you to influence WebRTC behavior in ways that are not supported by the standard WebRTC API. This enables advanced use cases like custom network configurations, DTLS tuning, and ICE optimization without deviating from the WebRTC API elsewhere.
The SettingEngine must be configured before creating a PeerConnection. Settings are applied when you create an API object with webrtc.NewAPI(webrtc.WithSettingEngine(s)).

Creating a Custom API

settingengine.go

ICE Configuration

Port Range

Limit the UDP port range for ICE candidate gathering:
port-range.go
From settingengine.go:264-279.

ICE Timeouts

Configure ICE connection timeouts and keepalive intervals:
ice-timeouts.go

Network Types

Control which network types are used for ICE candidates:
network-types.go

Interface and IP Filtering

Filter which network interfaces and IP addresses are used:
filtering.go
From settingengine.go:292-306.

NAT Traversal

NAT 1:1 IPs

Configure external IP addresses for servers behind NAT (e.g., AWS EC2 with Elastic IP):
nat-1to1.go
SetNAT1To1IPs is deprecated. Use SetICEAddressRewriteRules for more fine-grained control.

Address Rewrite Rules

Modern alternative to NAT1To1IPs with more control:
address-rewrite.go
From settingengine.go:345-368.

DTLS Configuration

Retransmission Interval

dtls-retransmit.go

Skip Hello Verify

dtls-skip-verify.go
Skipping HelloVerify reduces protection against DoS attacks. Only use in trusted environments.

Elliptic Curves

dtls-curves.go

Connection Context

Control DTLS handshake timeout:
dtls-context.go
From settingengine.go:543-552.

SCTP Configuration

Buffer Sizes

sctp-buffer.go

Zero Checksum

sctp-checksum.go
SCTP zero checksum is not backwards compatible. Only enable if both peers support it.
From settingengine.go:586-591.

Advanced Features

Single Port (UDPMux)

Serve multiple PeerConnections on a single UDP port:
udp-mux.go
See the full example at examples/ice-single-port/main.go.

ICE-TCP

Enable ICE over TCP:
ice-tcp.go
See the full example at examples/ice-tcp/main.go.

ICE Lite

Configure as ICE Lite agent:
ice-lite.go
From settingengine.go:281-284.

Custom Logging

Provide a custom logger factory:
custom-logger.go
See the full example at examples/custom-logger/main.go.

Data Channel Detach

Detach data channels for direct I/O access:
detach.go
From settingengine.go:199-204.

Replay Protection

DTLS/SRTP Replay Protection

replay-protection.go
From settingengine.go:432-457.

ICE Credentials

Set static ICE credentials for signalless WebRTC:
ice-credentials.go
From settingengine.go:418-425.

Complete Example

complete-example.go

MediaEngine

Configure codecs and RTP parameters

Interceptors

Modify RTP/RTCP packet processing

Custom Logging

Implement custom logging

ICE Configuration

Deep dive into ICE settings