# Signaling

> The Signaling is the process of exchanging connection details between peers before a WebRTC connection is established.

## What is signaling in WebRTC?

The process where peers exchange session descriptions and network candidates through any channel, usually a WebSocket server, before they can connect. WebRTC does not define how signaling works, so each app implements its own.

- Topic: Real-Time Communication
- Type: process

## Example

Wrong:

```js
const offer = await pc.createOffer();
ws.send(JSON.stringify({ type: 'offer', sdp: offer }));
```

Right:

```js
await pc.setLocalDescription();
ws.send(JSON.stringify({ type: 'offer', sdp: pc.localDescription }));
pc.onicecandidate = ({ candidate }) => {
  if (candidate) ws.send(JSON.stringify({ type: 'candidate', candidate }));
};
```

The offer is applied locally before sending, and ICE candidates are forwarded as they are found.

## Common mistakes

- Sending ICE candidates before the remote description is set and silently dropping them.

## Key points

- Offers, answers and ICE candidates are all forwarded to the other peer, not only the offer.
- The signaling channel requires authentication, so strangers cannot join a call.

## Interview questions

### Can I use HTTP instead of WebSocket for signaling?

Yes. Any channel that delivers messages works, including HTTP requests, though WebSocket is common because both sides can send at any time.

### What is trickle ICE?

Sending ICE candidates through signaling as soon as they are found, instead of waiting for all of them, which makes calls connect faster.

### Is the signaling server involved after the call starts?

Only for renegotiation, such as adding a track or restarting ICE. Media itself does not pass through it.

## Related cards

- [WebRTC](https://wonderium.dev/web/webrtc.md)
- [SDP](https://wonderium.dev/web/sdp.md)
- [ICE](https://wonderium.dev/web/ice.md)
- [WebSocket](https://wonderium.dev/web/websocket.md)

---

- Level: [Web Platform](https://wonderium.dev/web.md)
- HTML version: https://wonderium.dev/web/signaling
- Last updated: 2026-11-25
