I am using WebRTC for communication for media streaming between my android app and web app. For signalling I have used socket.io and using socket I have established the connection between android app and web app. I am able to send offer and receive answer on Mobile app and ideally after that the streaming should start but in my case it is throwing this error on the web.
WebRTC: ICE failed, your TURN server appears to be broken, see about:webrtc for more details
failed screen.js:835:25
Need to reconnect student screen.js:838:33
Ice Connecttion state Changed to disconnected|closed|failed
I think this is happening because connection can't be established with the TURN server. Can someone help me with this. I am using this piece of code for TURN server connection. Also please tell me how can i verify if my connection with TURN has been established.
try {
PeerConnection.IceServer peerIceServer1=PeerConnection.IceServer.builder("stun:stun.XXXXXX.com:3478")
.setUsername("XXXXXX")
.setPassword("XXXXXX")
.setTlsCertPolicy(PeerConnection.TlsCertPolicy.TLS_CERT_POLICY_INSECURE_NO_CHECK)
.createIceServer();
String username1 = "XXXXX";
String credential1 = "XXXXXX/XXXXXXXX=";
String turnUrll = "turn:turn.XXXX.com:3478";
PeerConnection.IceServer peerIceServer = PeerConnection.IceServer.builder(turnUrll)
.setUsername(username1)
.setPassword(credential1)
.setTlsCertPolicy(PeerConnection.TlsCertPolicy.TLS_CERT_POLICY_INSECURE_NO_CHECK)
.createIceServer();
peerIceServers.add(peerIceServer);
peerIceServers.add(peerIceServer1);
}
catch (Exception e){
e.printStackTrace();
}
This is the piece of code where i am trying to create peer connection.
private void createPeerConnection() {
PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(peerIceServers);
// TCP candidates are only useful when connecting to a server that supports
// ICE-TCP.
rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.ENABLED;
rtcConfig.bundlePolicy = PeerConnection.BundlePolicy.MAXBUNDLE;
rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.REQUIRE;
rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY;
// Use ECDSA encryption.
rtcConfig.keyType = PeerConnection.KeyType.ECDSA;
localPeer = peerConnectionFactory.createPeerConnection(rtcConfig,
new CustomPeerConnectionObserver("localPeerCreation") {
@Override
public void onIceCandidate(IceCandidate iceCandidate) {
super.onIceCandidate(iceCandidate);
onIceCandidateReceived(iceCandidate);
}
@Override
public void onAddStream(MediaStream mediaStream) {
showToast("Received Remote stream");
super.onAddStream(mediaStream);
}
});
addStreamToLocalPeer();
}
If anyone wants to have more better view of code i will share more details. please i need help since i can't even find the documentation for this.