Skip to main content
Triggered when a WebRTC ICE candidate is received through the unified WebSocket connection. ICE candidates are used to establish the optimal network path for WebRTC media streaming.

Event Properties

string
Event type. Always "webrtc.signaling.iceCandidate" for this event.
object
Event data object containing ICE candidate information.
object
The RTCIceCandidate object containing candidate information for network path discovery.Example:

Sending ICE Candidate

When ICE candidates are generated by your RTCPeerConnection, you need to send them immediately. Here’s how to send ICE candidates:
Message Structure: When sending an ICE candidate, the message structure should be:
RTCIceCandidate Object Properties: The candidate object should have the following properties:
  • candidate (string): The candidate string, e.g., "candidate:1666409998 1 udp 2122129151 192.168.1.81 64301 typ host generation 0 ufrag lwyK network-id 1"
  • sdpMLineIndex (number, optional): The SDP media line index, typically 0 for video or 1 for audio
  • sdpMid (string, optional): The SDP media identification tag, typically "0" for video or "1" for audio
  • usernameFragment (string, optional): The ICE username fragment (ufrag)
Key Points:
  • The candidate parameter in data.candidate should be an RTCIceCandidate object (or equivalent plain object)
  • Send ICE candidates immediately when they’re generated in the onicecandidate event handler
  • Only send candidates when event.candidate is not null (when it’s null, ICE gathering is complete)
  • You may receive multiple ICE candidates - send each one as it’s generated

Receiving ICE Candidate

When you receive an ICE candidate, handle it like this:
Complete Example:
  • When to send: Send ICE candidates immediately when they’re generated in the peerConnection.onicecandidate event handler
  • What to send: Send event.candidate (which is an RTCIceCandidate object) as the candidate value
  • Multiple candidates: You may receive multiple ICE candidates - send each one as it’s generated
  • ICE candidates are sent through the unified WebSocket connection