What browsers need
A WebRTC client differs from a desk phone in two ways, and Routr handles each one separately:- Signaling over WebSocket. Browsers can’t send SIP over UDP or TCP. They use SIP over WebSocket, and a page served over HTTPS can only open secure WebSockets (
wss://) to a server with a certificate the browser trusts. The EdgePort listens for WS on port5062and WSS on port5063. - Different media. WebRTC requires ICE and DTLS-SRTP, which most SIP phones and PBXs don’t speak. The RTPRelay middleware drives an RTPEngine instance that rewrites the SDP and relays media between the two sides. Routr itself never touches media.
Prerequisites
- A running Routr deployment. See Deploy with Docker or Deploy on Kubernetes.
- A certificate from a trusted CA for the host name browsers connect to. See Secure the server.
- An RTPEngine instance, or a host where you can run one, with a public IP and an open UDP port range.
Enable WebRTC
1
Open the WebSocket transports
- Docker (routr-one)
- Docker (split)
- Kubernetes (Helm)
The routr-one image already listens on
5062 (WS) and 5063 (WSS). Publish the ports you need in compose.yaml.compose.yaml
2
Run RTPEngine
RTPEngine needs a public IP and a UDP range for media, plus its control port (On Kubernetes, deploy RTPEngine yourself. The Routr chart doesn’t include it.
22222/udp by default). The following service uses the fonoster/rtpengine image from the Routr examples.compose.yaml
3
Enable RTPRelay
RTPRelay runs as a post-processor middleware: the Message Dispatcher calls it after the Connect processor, so it can rewrite the SDP of INVITEs, responses, and ACKs, and release media sessions on BYE.
- Docker (routr-one)
- Docker (split)
- Kubernetes (Helm)
Set
RTPENGINE_HOST. When it is set, routr-one starts RTPRelay and registers it as a middleware automatically. Set RTPENGINE_PORT if RTPEngine doesn’t use 22222.compose.yaml
4
Tune Agents for browsers
Browsers create a new SIP contact on every page load, and an old contact stays in the location table until its registration expires. If an Agent’s
maxContacts is low, new registrations fail with 403 Forbidden and the reason exceeds maximum of N allowed contacts.- Leave
maxContactsempty inrctl(stored as-1, no limit), or set it high enough for the tabs and devices you expect. - Register with a short expiry in the client and unregister when the page closes. The registration lifetime comes from the client’s
REGISTERrequest.
5
Point the client at Routr
Configure SIP.js or JsSIP with the WSS URL, the Agent’s SIP URI, and its credentials, for example:
Verify
Register a browser client, then call a desk softphone or a PBX Peer.The call connects with two-way audio in both directions: browser to phone and phone to browser.
Troubleshooting
- The browser can’t open the WebSocket. The page is served over HTTPS and you used
ws://, or the certificate isn’t trusted. Usewss://with a CA-issued certificate. - The call connects with no audio. RTPEngine’s
PUBLIC_IPis wrong, or its UDP port range isn’t reachable from the internet. - RTPRelay never runs. On a split deployment, the middleware isn’t listed in
dispatcher.yaml, or the EdgePort points directly at the Connect processor. - Registrations start failing after a few reloads. The Agent hit
maxContacts. See the previous step.
Related
Ephemeral agents in the browser
Register browser users with signed tokens instead of stored Agents.
RTPRelay reference
Environment variables and protocol.
EdgePort reference
Transports and the security context.
Helm values
The
rtprelay and dispatcher values.