WebRTC works on your laptop. Here is what breaks when you put it on a server.
The first article in this series covered the traps inside the code — the Pion v4 API changes, the SSRC rewrites, the renegotiation timing. This one is about the layer underneath it, where the failures look identical and have completely different causes. Everything below happened to me deploying a real-time streaming server to a cloud VM. None of it was a bug in my code, and all of it took longer…
This article discusses common issues encountered when deploying a real-time streaming server to a cloud virtual machine, as opposed to local deployment. The two main layers discussed are signaling and media, with their respective challenges.
Signaling relies on WebSockets, which use TCP and are covered by a reverse proxy for TLS. Media, on the other hand, uses RTP over UDP and is not touched by the reverse proxy or CDN. The major difference between the two paths is that WebSockets are not suitable for media streaming, and the reverse proxy does not handle media.
The article highlights three key traps to watch out for:
1. ICE candidates are often inaccurate: A cloud VM's private address is used when gathering ICE candidates, which cannot be reached over the internet. To resolve this, either use a STUN server to report a public IP address or explicitly configure the server with the public IP address. This avoids connection failures due to unreachable private addresses.
2. Firewalls and security groups: Cloud providers have two firewalls – one on the instance and one at the provider level (security group). The instance's firewall may need to be adjusted to open the appropriate ports for media streams. This firewall is often overlooked, leading to issues with media traffic that use UDP ports other than the default HTTP port.
Checking the WebRTC internals page (chrome://webrtc-internals or about:webrtc) can help determine if the issue lies in ICE candidate gathering (private vs. public address) or if it's a security group problem.
3. Reverse proxy idle socket handling: WebSockets carry signaling and are idle most of the time. Reverse proxies often have idle timeouts around 60 seconds, which can cause connections to be closed. This can lead to WebSocket sessions appearing healthy while the media stream fails due to idle timeouts.
Understanding these traps and implementing the suggested solutions can save significant time and frustration during deployment.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.
This story
This is one outlet's version. Read the fullest account.