Overview
TheCandidateType enum represents the type of ICE candidate as defined in RFC 5245. Each type indicates how the candidate address was obtained and affects its priority in the connection establishment process.
Type Definition
Types
CandidateTypeHost
- Highest priority (preference: 126)
- No STUN/TURN servers required
- Direct peer-to-peer connection
- Best latency and bandwidth
CandidateTypeServerReflexive
- Medium-high priority (preference: 100)
- Requires STUN server
- Reveals public NAT address
- Good for NAT traversal
"srflx"
CandidateTypePeerReflexive
- Medium priority (preference: 110)
- Discovered during connectivity checks
- Created automatically by the ICE agent
- Not gathered explicitly
"prflx"
CandidateTypeRelay
- Lowest priority (preference: 0)
- Requires TURN server
- Guaranteed connectivity
- Higher latency and bandwidth cost
- Most reliable for restrictive NATs
CandidateTypeUnspecified
Methods
String
"host"for CandidateTypeHost"srflx"for CandidateTypeServerReflexive"prflx"for CandidateTypePeerReflexive"relay"for CandidateTypeRelay"Unknown candidate type"for CandidateTypeUnspecified or invalid values
Preference
126for CandidateTypeHost110for CandidateTypePeerReflexive100for CandidateTypeServerReflexive0for CandidateTypeRelay and CandidateTypeUnspecified
Priority Order
Usage Examples
Default Behavior
When no candidate types are specified, all three gatherable types are enabled:Peer reflexive candidates are never explicitly gathered. They are discovered automatically during connectivity checks and don’t need to be specified in the candidate types list.
Server Requirements
| Candidate Type | Required Servers |
|---|---|
| Host | None |
| Server Reflexive | STUN server |
| Peer Reflexive | None (discovered) |
| Relay | TURN server |
NAT Traversal
Best case (Direct connection):Address Rewrite Rules
You can specify which candidate type to use for address rewriting:Acceptance Timing
You can configure minimum wait times before accepting each candidate type:Related
- Agent Options - WithCandidateTypes configuration
- Candidate Types - Candidate implementations
- Host Candidate - Host candidate details
- Server Reflexive Candidate - Srflx candidate details
- Peer Reflexive Candidate - Prflx candidate details
- Relay Candidate - Relay candidate details