Atlas Knowledge Base
Dashboard
WebRTC Peer

WebRTC Peer

The WebRTC Peer service - connects SBN Video clients to a camera or call, and sets up peer-to-peer connections for applications such as Foresight and Safe and Secure.

configuration
ice
peer-to-peer
sbn-media
video
webrtc
webrtc-peer
webrtcpeer

WebRTC Peer

The WebRTC Peer sets up live media connections using WebRTC. It connects a browser-based SBN Video client to a camera or a call, and it also sets up direct peer-to-peer connections between two parties.

Overview

When an SBN Video client opens a live stream, the WebRTC Peer establishes the connection: it negotiates the audio and video, works out the network path to use, and links the client to the device stream. It works together with the API Proxy, which the client connects through, and the TURN server, which relays the media when a direct path is not possible.

The same service also sets up peer-to-peer connections that link two parties directly to each other rather than to a camera. Applications such as Foresight and Safe and Secure use this to connect people together.

In every case it uses the best path available - a direct connection where the network allows it, and a relay through the TURN server on more restrictive networks - and hands each side the STUN and TURN details it needs to connect.

  1. Runs: When configured. A deployment can run more than one to carry more concurrent video sessions.
  2. Required: Required to serve live video to browser clients.
  3. Depends on: NATS, the API Proxy (the client's entry point), and the TURN server (or an external TURN server) for firewall traversal.

Configuration

The WebRTC Peer is configured under the webrtcpeer namespace. View the defaults with ./sbn-media config eject and set host-specific overrides in sbn-media.local.yaml.


Setting

Default

Description

webrtcpeer.stunServers

a public STUN server

The STUN servers used to discover the public network path.

webrtcpeer.disableInternalTurnServer

false

Turn off the built-in TURN server and use an external one instead.

webrtcpeer.turnServer.url

empty

The address of an external TURN server, used when the built-in one is turned off.

webrtcpeer.turnServer.username

empty

The username for the external TURN server.

webrtcpeer.turnServer.credential

empty

The credential for the external TURN server.

webrtcpeer.nat1to1IPs

empty

The host's public address, needed when it differs from the address the host binds to, so clients are offered an address they can reach.

webrtcpeer.codec.video

video/h264

The video codec offered to clients.

webrtcpeer.codec.audio

audio/opus

The audio codec offered to clients.

webrtcpeer.deviceConnectionTimeout

5

How long, in seconds, to wait when connecting to a device before giving up.

webrtcpeer.controlMessageTimeoutInSeconds

20

How long, in seconds, to wait for a control message to a device.

Example:

webrtcpeer:
# The STUN servers used to discover the public network path.
stunServers:
- stun:stun.l.google.com:19302

# The host's public address, if it differs from the address it binds to.
nat1to1IPs:
- "203.0.113.10"

After changing these settings in sbn-media.local.yaml, reload the configuration for them to take effect.

FAQ

Video does not connect for remote clients. What should I check?

This is almost always firewall traversal. Confirm the TURN server is reachable from clients (see the TURN Server page), and set webrtcpeer.nat1to1IPs to the host's public address when it differs from the address the host binds to. If the service will not start, run it in the foreground with sbn-media service exec webrtcpeer -ld to see the error.

Can I use an external STUN or TURN server?

Yes. List external STUN servers in webrtcpeer.stunServers. To use an external TURN server, set webrtcpeer.disableInternalTurnServer to true and provide its address and credentials in webrtcpeer.turnServer.

How many WebRTC Peer services do I need?

One is enough to start. Run more to carry more concurrent video sessions; the load is shared across them.

Which audio and video formats are used?

H.264 video and Opus audio by default, chosen for broad browser support. These are set by webrtcpeer.codec.video and webrtcpeer.codec.audio.

Related pages

  1. SBN Media Overview (SBN-Media/overview)
  2. Installing and Configuring SBN Media (SBN-Media/installation)
  3. API Proxy (SBN-Media/Platform/api-proxy)
  4. TURN Server (SBN-Media/Telephony/turn-server)




Was this helpful?