DEV Community

Connect Two WebRTC Peers with Manual Signaling

WebRTC does not define how two peers exchange connection details. Normally that job belongs to a WebSocket or HTTP signaling service. For debugging, copy and paste is enough:

Device A: Offer + ICE -> invitation
Device B: invitation -> Answer + ICE -> answer code
Device A: apply answer -> connect

Try it

Open the manual signaling tester on both devices. Use HTTPS and allow at least one media source. Select Manual signaling (P2P) on both pages, then start capture.

Device A

  • Select Start a connection.
  • Create an invitation.
  • Wait for ICE gathering to finish.
  • Send the complete invitation to device B.

Waiting matters: candidates may still be added after setLocalDescription() returns.

Device B

  • Select Join a connection.
  • Paste the invitation.
  • Create the answer code.
  • Send it back unchanged.

The receiver is effectively doing this:

await peer . setRemoteDescription ( offer );
const answer = await peer . createAnswer ();
await peer . setLocalDescription ( answer );

Back on device A

Paste and apply the answer:

await peer . setRemoteDescription ( answer );

ICE will now choose a viable candidate pair or report failure.

If it does not connect

Check these before rewriting your signaling code:

  • The copied code was not truncated or reformatted.
  • The Answer belongs to the current session.
  • Both pages captured at least one media source.
  • ICE candidates exist in the Offer and Answer.
  • A firewall or symmetric NAT is not blocking the path.

STUN discovers public mappings; it does not relay media. Strict networks may require TURN.

Scope

Manual signaling is useful for understanding Offer/Answer order, inspecting SDP, and separating signaling errors from connectivity errors. It is not suitable for production rooms, authentication, reconnects, or reliable NAT traversal.

The flow was verified with two independent pages in one browser context, including remote media tracks and session mismatch rejection. Physical-device and cross-network behavior still needs testing in the target environment.

Comments

No comments yet. Start the discussion.