How to fix unreliable WebRTC calling?

情到浓时终转凉″ 提交于 2019-12-10 15:16:20

问题


WebRTC calls are not reliable in our application. Sometimes we see the black screen, sometimes we don’t see call start at all and sometimes there are seen huge delays or de-sync in audio/video.

Setup:

  • Google’s public STUN server stun:stun.l.google.com:19302;
  • TURN server is Coturn hosted in azure in docker;
  • Signaling server is a customized https://github.com/andyet/signalmaster that using express as a web server
  • On client JS is used, with simplewebrtc as client;
  • For iOS support used Cordova plugin - https://github.com/eface2face/cordova-plugin-iosrtc

Almost 100% reproduced issue is calling from one client on LTE to another on Wi-Fi. In this case we see black screen on both devices, however, default bg-color is white, so at least something happens on WebRTC side.

What was done to address issues:

  • Examined Coturn logs... Sometimes we see "Unauthorized" errors there, but it's hard to say if they affect anything;
  • Checked Coturn's traffic: in Wi-Fi to Wi-Fi scenarios it is low, so peer-to-peer connection is really made. If there is LTE, we see around 40–120KiB/sec load (Isn't that too low for audio/video?), so TURN seems to work;
  • Checked client app logs, nothing special;

Please, suggest any possible way of research or fix to make WebRTC as much reliable as possible.


回答1:


The above scheme is from this article I wrote which goes into a lot of detail on this topic.

Shortly, problems can appear in any of the 3 steps:

  1. signaling
  2. discovery using STUN/TURN
  3. p2p connection

Here's what I would do:

  1. Use a low minimum resolution in constraints like 320x240, this will make sure there are no simple to avoid getUserMedia() errors
  2. Make sure signaling is done over port 80 or 443
  3. In many cases a peer can not communicate with the STUN/TURN servers so try communicating with STUN/TURN using TCP (stun:stun.l.google.com:19302?transport=tcp) and port 80 (default is UDP port 3478 or 19302 for Google's STUN and they might be blocked by your router/firewall/proxy/mobile network )
  4. Use TrickleICE (with your own STUN/TURN) and the WebRTC Troubleshooter on the LTE/WiFi devices and you'll learn a lot about how they can be connected to


来源:https://stackoverflow.com/questions/42836729/how-to-fix-unreliable-webrtc-calling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!