The app: I'm developing app that allows peers to connect to each other, I use mediasoup and WebRTC (SFU).
The problem: Everything works locally but when deployed to VPS (I use Vultr) peers can not connect. On VPS firewall ports are open for the range declared in mediasoup (tcp and udp).
I went through several questions here on stackoverflow but unfortunatelly none of it helps:
- set up TURN server: WebRTC connection does not establish after successful signaling How do I configure WebRTC to connect to my TURN server?
I use metered.ca, and I pass configuration on the client side:
producerTransportRef.current = deviceRef.current.createSendTransport({
...params,
iceServers: [
{
urls: 'stun:stun.relay.metered.ca:80',
},
{
urls: 'turn:a.relay.metered.ca:80',
username: 'XXX',
credential: 'YYY',
},
{
urls: 'turn:a.relay.metered.ca:80?transport=tcp',
username: 'XXX',
credential: 'YYY',
},
{
urls: 'turn:a.relay.metered.ca:443',
username: 'XXX',
credential: 'YYY',
},
{
urls: 'turn:a.relay.metered.ca:443?transport=tcp',
username: 'XXX',
credential: 'YYY',
},
],
});
params come from the server from defining mediasoup transport and are passed to the frontend where are merged with TURN server configs:
let transport = await router.createWebRtcTransport(webRtcTransport_options);
callback({
// https://mediasoup.org/documentation/v3/mediasoup-client/api/#TransportOptions
params: {
id: transport.id,
iceParameters: transport.iceParameters,
iceCandidates: transport.iceCandidates,
dtlsParameters: transport.dtlsParameters,
},
});
When I print the iceCandidate I get from the server there's my server ip address
When I run webrtc-internals in chrome I get:
I followed the error code:
701 error code - If no host candidate can reach the server, errorCode will be set to the value 701 which is outside the STUN error code range.
I noticed that the host candidate is in my local network (not sure if that's the problem)
I'd highly appreciate even suggestions on what to check next