0

If the broadcaster app (Android) and client app(IOS and Android) are connected to wifi in the same network, everything works fine. But when the broadcaster app is connected to mobile data connection, client app (IOS) shows black screen but the Android still works fine. I have searched some work around with this and they suggest to add STUN and TURN in my peerConnection , but i had already added before . Seems not working when the communication is stablished on different network connection. This is how i setup my RTCPeerConnection.

 var rtcIceServers: [RTCIceServer] = []
    rtcIceServers.append(RTCIceServer(urlStrings: [turnUrl], username:"*****",credential: "*********"))
    rtcIceServers.append(RTCIceServer(urlStrings: [stunUrl]))
    
    let rtcConf = RTCConfiguration()
    rtcConf.iceServers = rtcIceServers
    rtcConf.tcpCandidatePolicy = .disabled
    rtcConf.bundlePolicy = RTCBundlePolicy.maxBundle
    rtcConf.rtcpMuxPolicy = RTCRtcpMuxPolicy.require
    rtcConf.continualGatheringPolicy = RTCContinualGatheringPolicy.gatherContinually
    rtcConf.keyType = .ECDSA
      let mediaConstraints = RTCMediaConstraints.init(mandatoryConstraints: mandatoryConstraints, optionalConstraints: nil)
    let pc = self.peerConnectionFactory.peerConnection(with: rtcConf, constraints: mediaConstraints, delegate: self)

the client app requires only to receive video track , no audio added in the mandatory constraints. Thank you

  • What server are you using? Like janus or kurento? – hessam Feb 16 '21 at 11:31
  • @hessammahdiabadi as what i saw in my logs they are not using either of the server, i just saw the js file of signaling server ,they have their own ip address used for TURN and STUN – Peter Mora Feb 17 '21 at 08:38
  • Have you ever tried the this repo https://github.com/tkmn0/SimpleWebRTCExample_iOS? I used it and it worked. My suggestion is to work with this link first and if you succeed, connect to your own signal. – hessam Feb 17 '21 at 09:08
  • that one actually my first source of info about Webrtc , most of my code are the same i just remove some unnecessary line of codes , thank you for that – Peter Mora Feb 17 '21 at 09:34
  • i have also tried testing my STUN and TURN here https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/ and it works fine – Peter Mora Feb 17 '21 at 09:36

1 Answers1

0

After few days of debugging and comparing my setup to other sources, i resolved the issue by applying the right parameters to my RTCIceCandidate before i add to my peerConnection. I mistakenly applied candidate value to sdpMid parameter and id value to sdp parameter. Since everything works if both clients are in the same network connection, i never suspect my parameters, not until i understand quite a bit about why i need to use IceServers when clients are not in the same network. So RTCIceCandidate value is not quite important and also these ice servers when clients are in the same network thats why it was working even if RTCIceCandidate has wrong parameters applied. My bad...

RTCIceCandidate(sdp: id, sdpMLineIndex: label, sdpMid: candidate)// wrong



RTCIceCandidate(sdp: candidate, sdpMLineIndex: label, sdpMid: id)// correct