iOS & Safari 11 WebRTC does not gather STUN/TURN Trickle ICE Candidates

耗尽温柔 提交于 2019-12-06 06:59:40

问题


My web application is failing to gather WebRTC relay ICE candidates via a CoTURN server when using Safari 11 on iOS 11 (iPhone 5s & iPhone 7) or desktop. The web application (which establishes a one-way audio only WebRTC peer connection) works fine between the real browsers (Chrome and Firefox) either direct or via CoTURN relay, and I normally get 6-15 ICE candidates on these browsers.

I have a (frankly, unnecessary) call to getUserMedia on the receiving side, which allows host ICE candidates to be produced by Safari. (Note... the user must approve audio and/or video access before Safari will provide host Ice Candidates, even if on a receiving-only end. I'm past that hurdle, but just so you won't hit it too... This is out of "privacy" concerns.). Before I added the allow getUserMedia, I received no ICE. Now I receive two candidates. One with a private IPv4 and another with an IPv6. This is enough to get the app working properly when on the same machine or local network. So I'm pretty confident with other parts of the application code. I am not sure if my problem is with the application code or the CoTURN server.

Example of the ICE candidates received:

{"candidate":{"candidate":"candidate:622522263 1 udp 2113937151 172.27.0.65 56182 typ host generation 0 ufrag r23H network-cost 50","sdpMid":"audio","sdpMLineIndex":0,"usernameFragment":"r23H"}}

I pretty sure the RTCIceServer Dictionary for my RTCPeerConnection is inline with the following standards:

  • https://w3c.github.io/webrtc-pc/webrtc.html
  • https://tools.ietf.org/html/rfc7064
  • https://tools.ietf.org/html/rfc7065

And I've tried multiple variations of parameters:

// For Example:
var RPCconfig = {
    iceServers: [{ 
        urls: "turn:Example.live",
        username: "un",
        credential: "pw"
        }] 
     };

// Or:    
var RPCconfig = {
    iceServers: [{ 
        urls: "turns:Example.live",
        username: "un",
        credential: "pw",
        credentialType: "password"
        }, {
        urls: "stun:Example.live"
        }] 
    };

// And even more desperate attempts...
var RPCconfig = {
    iceServers: [{ 
        urls: "turn:Example.live?transport=tcp",
        username: "un",
        credential: "pw",
        credentialType: "password"
        }] 
};

Here's an example of the signaling process log for an idea of what is going on. This is from the receiving side, which is Safari 11. The other browser was Chrome (compare 6 vs 2 ICE candidates). The state change refers to oniceconnectionstatechange.

SDP Offer received. 
Sending signal SDP 
Sending signal IceCandidate
Sending signal IceCandidate 
ICE Candidate Received 
4:08:25 AM State Change -> checking 
ICE Candidate Received 
ICE Candidate Received 
ICE Candidate Received 
ICE Candidate Received 
ICE Candidate Received
4:08:40 AM State Change -> failed

CoTURN is configured quite liberally in terms of accepting every possible transport method as far as I am aware. It works well for providing ICE Candidates and as a relay for the other browsers.

Any direction would be greatly appreciated. Even if it is just a sample RTCIceServer Dictionary code that works or a proven TURN server to try.

来源:https://stackoverflow.com/questions/46605141/ios-safari-11-webrtc-does-not-gather-stun-turn-trickle-ice-candidates

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