I'm working on an Angular app that uses webRTC. The purpose of this app is to display a video stream coming from a software running on a Google Cloud Platform VM, and being transmitted through WebRTC. I'm using WebSocket for the signaling phase because the software provides a WebRTC feature, and this feature contains a WebSocket server for the signaling phase. When I run it locally (i.e. running the web app on the GCP VM), it works perfectly (the webRTC connection is established and I receive the video).
The problem comes when I run the web app on another network. I know that WebRTC relies on STUN and TURN servers. In my specific case, a STUN server should not work since the GCP VM doesn't have an external (public) IP address. In this case I need a TURN server, right ?
For testing purposes, I am using a public TURN server :
iceServers = [
{ urls : turn:freeturn.net:3478,
username : "free",
credential : "free"
}
]
But here comes the problem : When I try to establish the webRTC connection with my web app running on another machine (not the GCP VM), the connection gets stuck in "connecting" state, and the ice candidate state is "checking". And after few seconds, the connection times out. I don't understand what I am doing wrong (of course I added the TURN server in the configuration of my WebRTC connection).
One last important thing is that since my VM doesn't have an external IP, I had to find a workaround to successfully establish the webSocket connection for the signaling phase. This workaround is a simple SSH SOCKS proxy. Maybe this proxy could be the reason why my connection is stuck ?
I've of course tried to debug this mess, and apparently the web app wants to use the TURN server as the ICE candidate (as it should), but it looks like the server does not choose this TURN server.
Do you have any clue why my connection gets stuck ? I can provide anything you need, just ask.
I've tried with the TURN server and without, and it doesn't change a thing. I also checked that the TURN server works using TrickleICE (https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/) and it seems to be working. The only little detail is that every time I add it in my configuration, I receive the icecandidateerror 701, which is not necessarily fatal if I understood correctly all the different things I've read about that.
Thank you !
Update : maybe this will help someone, but the problem was that all the public STUN/TURN servers were not working properly. I implemented my own server using Coturn and now it works perfectly !