Does WebRTC Use WebSockets? (And When You Should)
People setting up WebRTC calling often ask whether WebRTC uses WebSockets under the hood. The short answer is no for the audio and video, but very often yes for the signalling that sets the call up. For anyone connecting a browser to a phone system, WebSockets are usually the link between the browser and the PBX.
How WebRTC carries the media
WebRTC sends audio and video as SRTP: the Real-time Transport Protocol with encryption, keyed through DTLS. It runs over UDP wherever possible, because late audio is worse than lost audio. Data channels use a different protocol again (SCTP over DTLS). None of this travels over a WebSocket. For more on the transport question, see Is WebRTC UDP or TCP?
Before any media can flow, the two ends have to agree on codecs, network addresses and encryption keys. That exchange is called signalling, and the WebRTC standard deliberately leaves it to the application.
Where WebSockets come in
Because WebRTC does not define signalling, developers pick their own transport for it, and WebSockets are the most common choice. A WebSocket is a long-lived, two-way connection between the browser and a server, which suits signalling well. Over it you might:
- exchange SDP offers and answers, which describe the media each side can send and receive;
- send ICE candidates, the possible network addresses each side can be reached on;
- carry call control such as ringing, hold and hang-up.
SIP over WebSocket: how browsers talk to phone systems
For business calling, the most important use of WebSockets is SIP over WebSocket, defined in RFC 7118. A browser softphone uses a JavaScript SIP library to send ordinary SIP messages (REGISTER, INVITE, BYE) to the PBX over a secure WebSocket, and the media then flows as WebRTC. Asterisk, FreeSWITCH, Kamailio and OpenSIPS all accept SIP over WebSocket. Siperb’s knowledge base explains what a WebSocket connection is in this context, and how WebRTC works with SIP covers the full call flow.
WebRTC and WebSockets compared
- Purpose: WebRTC carries real-time audio, video and data; a WebSocket is a persistent channel between a browser and a server.
- Transport: WebRTC media uses SRTP, usually over UDP, with TCP or TLS through a relay as a fallback; WebSockets always run over TCP.
- NAT traversal: WebRTC has it built in (ICE with STUN and TURN); a WebSocket is an outgoing connection to a server, so it rarely needs any.
- Media: WebRTC is built for it; a WebSocket carries text or binary messages and is not suited to live audio.
For a wider comparison that also covers WebTransport, see DataChannel vs WebTransport vs WebSockets.
Good practice
- Always use secure WebSockets (
wss://). Browsers block insecure connections from secure pages, and signalling carries information you do not want exposed. - Keep the signalling channel for signalling. Once the call is set up, the media takes its own path: directly between two browsers, or between the browser and the PBX or media server.
- Provide a TURN server for networks that block direct media. A working WebSocket only proves that signalling can get through; it says nothing about whether the media can.
Final thoughts
WebRTC does not use WebSockets for media, but most real deployments use a WebSocket for signalling, and every browser softphone that talks SIP to a PBX depends on one. Knowing which traffic goes where makes it much easier to work out why a call rings but has no audio.
Updated 12 November 2026: corrected the media transport description (SRTP with DTLS keying, data channels over SCTP), added SIP over WebSocket (RFC 7118) for PBX users, and replaced the comparison table.
Related: WebRTC vs SIP: how they work together in internet calling.