RTCIceCandidate.relatedAddress

The RTCIceCandidate interface's read-only relatedAddress property is a string indicating the related address of a relay or reflexive candidate. If the candidate is a host candidate (that is, its ip is in fact the real IP address of the remote peer), relatedAddress is null.

The relatedAddress field's value is set when the RTCIceCandidate() constructor is used. You can't specify the value of relatedAddress in the options object, but the address is automatically extracted from the candidate a-line, if it's formatted properly, being taken from its rel-address field.

The related address and port (relatedPort) are not used at all by ICE itself; they are provided for analysis and diagnostic purposes only, and their inclusion may be blocked by security systems, so do not rely on them having non-null values.

Syntax

var relAddress = RTCIceCandidate.relatedAddress;

Value

A DOMString which contains the candidate's related address. For both peer and server reflexive candidates, the related address (and related port) are the base for that server or peer reflexive candidate. For relay candidates, the related address and port are set to the mapped address selected by the TURN server.

For host candidates, relatedAddress is null, meaning the field is not included in the candidate's a-line.

Usage notes

The related address is included in ICE candidates despite not being used by ICE itself. relatedAddress can be used for diagnostic purposes; by observing the relationships between the various types of candidates and their addresses and related addresses. relatedAddress can also be used by Quality-of-Service (QoS) mechanisms.

Here's an SDP attribute line (a-line) describing an ICE candidate discovered by the STUN server:

a=candidate:4234997325 1 udp 2043278322 192.168.0.56 6502 typ srflx raddr 192.168.2.77 rport 32768 generation 0

The remote address, relatedAddress, is the dotted quad (for IPv4) or colon-delineated 64-bit address (for IPv6) immediately following the text "raddr", or "192.168.2.77".

Example

In this example, the candidate's type is checked, and then debugging output is presented, based on the candidate type, including the candidate's ip and relatedAddress.

switch(candidate.type) {
  case "host":
    console.log("Host candidate's IP address is " + candidate.ip);
    break;
  case "srflx":
    console.log("Server reflexive candidate's base address is " +
        candidate.relatedAddress + "; reachable at " + candidate.ip);
    break;
  case "prflx":
    console.log("Peer reflexive candidate's base address is " +
        candidate.relatedAddress + "; reachable at " + candidate.ip);
    break;
  case "relay":
    console.log("Relay candidate's address assigned by the TURN server is " +
        candidate.relatedAddress + "; reachable at " + candidate.ip);
    break;
}

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCIceCandidate.relatedAddress' in that specification.
Candidate Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome No support NoEdge Full support YesFirefox No support NoIE No support NoOpera No support NoSafari ? WebView Android No support NoChrome Android No support NoEdge Mobile Full support YesFirefox Android No support NoOpera Android No support NoSafari iOS ? Samsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

Contributors to this page: Sheppy
Last updated by: Sheppy,