Can't fetch relay candidates even though my STUN/TURN servers are working
See original GitHub issueOnce I set local description on the peer connection object, the ice pc.onicecandidate
event is fetching all candidates except the relay one, with my server’s IP address.
Here’s the screenshot of the console log for each new candidate I’m receiving: https://imgur.com/a/3eRMjB0
I’ve checked both STUN and TURN servers on Trickle ICE, and I’m getting all candidates, including the relay candidates with the IP address of my public server (it’s hosted on DigitalOcean). I’m also using Coturn, with the default configuration.
0.166 | 1 | relay | 3 | udp | {my public server's IP address} | 63254 | 5 \| 32542 \| 255
Am I doing something wrong?
mediaDevices.enumerateDevices().then(sourceInfos => {
console.log(sourceInfos);
let videoSourceId;
for (let i = 0; i < sourceInfos.length; i++) {
const sourceInfo = sourceInfos[i];
if (sourceInfo.kind === "videoinput" && sourceInfo.facing === (isFront ? "front" : "environment")) {
videoSourceId = sourceInfo.deviceId;
}
}
mediaDevices.getUserMedia({
audio: true,
video: {
mandatory: {
minFrameRate: 30
},
facingMode: (isFront ? "user" : "environment"),
optional: (videoSourceId ? [{ sourceId: videoSourceId }] : [])
}
})
.then(async (stream) => {
this.setState({ localStream: stream });
const configuration = {
"iceServers": [{
"urls": "turn:*********:3478",
credential: "**********",
username: "**************"
}, {
"urls": "stun:**********:3478",
}]
};
const pc = new RTCPeerConnection(configuration);
const socket = this.socket;
const meetingID = this.meetingID;
pc.onnegotiationneeded = (event) => {
console.log(event);
pc.createOffer().then(desc => {
pc.setLocalDescription(desc).then(() => {
// Send pc.localDescription to peer
socket.emit("send-offer", {
meetingID: meetingID,
offer: pc.localDescription
});
});
});
}
this.socket.on("remote-description", async (description) => {
const remoteDesc = new RTCSessionDescription(description);
await pc.setRemoteDescription(remoteDesc);
});
pc.onicecandidateerror = function (event) {
console.warn(event);
}
pc.onicecandidate = function (event) {
console.log(event.candidate);
if (event.candidate) {
socket.emit("to-host-new-ice-candidate", { meetingID: meetingID, iceCandidate: event.candidate });
}
};
this.socket.on("new-ice-candidate", async data => {
if (data.iceCandidate) {
try {
await pc.addIceCandidate(data.iceCandidate);
} catch (e) {
console.log("ICE error: ", e);
this.props.navigation.goBack();
}
}
});
const ref = this;
pc.oniceconnectionstatechange = function (event) {
console.log("Change: ", event);
}
pc.addStream(stream);
pc.onaddstream = function (event) {
console.log(event.stream);
ref.setState({ remoteStream: event.stream });
}
pc.onconnectionstatechange = function (event) {
if (pc.connectionState === "connected") {
// connected
} else {
ref.setState({ remoteStream: stream });
}
}
})
.catch(error => {
console.log(error);
Alert.alert("Error", "Media stream error.")
});
});
Platform information
- React Native version: 0.63.2
- Plugin version: 1.84.0
- OS: Android
- OS version: Android 7.1.1 on both emulator and the physical device
Issue Analytics
- State:
- Created 3 years ago
- Comments:14
Top Results From Across the Web
how to test/troubleshoot simple coturn setup for webrtc?
I'm trying to get a TURN server using coturn working to relay for me with this config. var config = { 'iceServers': [...
Read more >Troubleshooting WebRTC Connection Issues - Deconstruct
Relay : These are generated the same way as a Server Reflexive candidate. The query message is sent to the TURN server creating...
Read more >Coturn server - Relay is not working - Stack Overflow
For some of the networks the STUN candidates are constantly failing, so I need to get a TURN server to relay the stream....
Read more >WebRTC TURN Servers: When you NEED it • BlogGeek.me
The NAT traversal servers in WebRTC are in charge of making sure the media gets properly connected. These servers are STUN and TURN....
Read more >Troubleshooting TURN - Giacomo Vacca
'host', 'server reflexive' and 'relay' candidates are left to compete with ... If the STUN Binding Request is received by the TURN server, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just tried Xirsys. Nope, same results.
Xirsys you dont need to buy - they offer you a free developer account
Google’s STUN server wont give you TURN /relay results because its a stun server, not a turn server.
onicecandidate of null means it finished gathering