Hellothere
Hellothere

Reputation: 263

Why is webRTC so glitchy? Code is the same, but "sometimes it doesn't work, sometimes it works"?

I am testing my webrtc application with localhost... It is the weirdest thing. Sometimes it connects perfectly, displaying both local and remote video on both of my windows.

Sometimes on one of the windows it can't display the remote video properly, so the remote video is just "stuck" on one image, and isn't "moving". It's frozen I guess, but the other window can still receive the remote video just fine. So it's like a one sided connection.

Sometimes, the webrtc doesn't even connect at all.

I have gotten all of these things happen, BUT the code is the same. Why is webrtc so weird?

Has anyone else had the same problems?

Upvotes: 1

Views: 1004

Answers (1)

dvhh
dvhh

Reputation: 4750

You are touching the main issue with P2P protocol, as you need your two peer to connect to each other ( sound simple, but it is complex on the internet ).

It really depend on your network topology between your two computer.

Direct connection

Peer 1 --- Peer 2

this situation is perfect as there is no obstacle for 1 to connect to 2 and vice versa

Routed connection

Peer 1 --- Router --- Peer 2

You everyday situation on the internet, the ability for 1 to connect to 2 heavily depend on your router configuration (and more than often, you don't control the configuration of the routers that are in between). To overcome that situation there was multiple solution that were developed :

  • uPnP : The Computer tells the router which port the computer is listening on that the router should be listening to and transfer the packet to the computer. It has a somewhat ok adoption rate but suffer from security issues.
  • Stun and Turn Servers

I real world scenario, peer to peer network rely on supernode to relay traffic in such case, there is nosuch thing for webRTC (except if you count Turn servers), as they would need to carry the charge of realtime video/audio traffic wich could be heavy when scaled to a lot of client.

Upvotes: 1

Related Questions