peerjs icon indicating copy to clipboard operation
peerjs copied to clipboard

Impossible to connect with some mobile providers

Open bilo1967 opened this issue 5 years ago • 9 comments

Hello. I've set up two minimal data connections (see below). It's just plain html and javascript, no JQuery. I only include a tool (here) to redirect window.console to a string resolving circular references, so I can easily download the logs. In any case the problem persists also without this tool. PeerJS is latest v1.2.0.

Each peer has a fixed name and they both connect to the default server with debug level 3:

  • A connects to PeerJS server (if the ID is not in use)
  • B connects to PeerJS server (if the ID is not in use)
  • A sends a text message to B when the user clicks a button
  • B receives and displays the text.

It's basically the same example from the API documentation. It works with most connections but I've found that it doesn't for some mobile providers (e.g Wind/3 Italy). Logs for both A and B are below. In these logs A is opened on a public real IP (no NAT). B is loaded from one of such providers (Wind/3 Italy).

I understand that at the momnent the default TURN server could be overloaded so I tried also with my own peerjs server and TURN/STUN server but the result is the same. I've also set up error handlers for both peer and data connection but no error is thrown.

Any idea on what is going wrong?

Code for A:

redirectConsole(); // logs goes now both to console and to string saveLog 

var id1 = "memine1231231-1";
var id2 = "memine1231231-2";

var start_button = document.getElementById('start-button');
var stop_button = document.getElementById('stop-button');
var chat_board = document.getElementById('chat-board');
var download_logs = document.getElementById('download-logs');


var peer = new Peer(id1, {debug:3});

peer.on('open', function(id) {

    chat_board.innerHTML = 'My peer ID is: ' + id;

    var conn = null;
    
    start_button.onclick = () => {

        conn = peer.connect(id2);
        conn.on('open', function() {
            // Receive messages
            conn.on('data', function(data) {
                console.log('Received', data);
            });
            // Send messages
            conn.send('Hello!');
        });
        
        conn.on('error', (e) => {
            chat_board.innerHTML += JSON.stringify(e);
        });
    }
});

peer.on('error', (e) => {
    chat_board.innerHTML += JSON.stringify(e);
});

stop_button.onclick = () => {
    peer.destroy();
};


window.addEventListener('beforeunload', function(event) {
    peer.destroy();
});

download_logs.onclick = function() {
    this.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(saveLog));
    this.setAttribute('download', 'log.txt');
}

A is online here.

Code for B:

redirectConsole(); // logs goes now both to console and to string saveLog 

var id1 = "memine1231231-1";
var id2 = "memine1231231-2";

var stop_button = document.getElementById('stop-button');
var chat_board = document.getElementById('chat-board');
var download_logs = document.getElementById('download-logs');

var peer = new Peer(id2, {debug: 3});

peer.on('open', function(id) {

    chat_board.innerHTML = 'My peer ID is: ' + id;
    
    peer.on('connection', (conn) => {
        // Receive messages
        conn.on('data', function(data) {
            chat_board.innerHTML += "<br/>Data: " + data;
        });
        conn.on('error', (e) => {
            chat_board.innerHTML += JSON.stringify(e);
        });        
    });
});

peer.on('error', (e) => {
    chat_board.innerHTML += JSON.stringify(e);
});

stop_button.onclick = () => {
    peer.destroy();
};

window.addEventListener('beforeunload', function(event) {
    peer.destroy();
});

download_logs.onclick = function() {
    this.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(saveLog));
    this.setAttribute('download', 'log.txt');
}

B is online here.

Logs from A:

[18/05/2020 14:09:05 - log] PeerJS:  Socket open
[18/05/2020 14:09:05 - log] PeerJS:  Server message received: {"type":"OPEN"}
[18/05/2020 14:09:21 - log] PeerJS:  Creating RTCPeerConnection.
[18/05/2020 14:09:21 - log] PeerJS:  Listening for ICE candidates.
[18/05/2020 14:09:21 - log] PeerJS:  Listening for data channel
[18/05/2020 14:09:21 - log] PeerJS:  Listening for remote stream
[18/05/2020 14:09:21 - log] PeerJS:  add connection data:dc_7ro8swubsrq to peerId:memine1231231-2
[18/05/2020 14:09:21 - log] PeerJS:  Created offer.
[18/05/2020 14:09:21 - log] PeerJS:  Set localDescription: {"type":"offer","sdp":"v=0\r\no=- 8597033948884117079 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:uEjt\r\na=ice-pwd:ZC8u2+3M1KWPSYKoTXWsk/WI\r\na=ice-options:trickle\r\na=fingerprint:sha-256 52:10:38:F9:57:64:B0:F0:76:D4:24:87:8E:58:6F:8D:75:0A:84:05:96:64:82:13:93:A2:26:A4:B9:8B:4B:28\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"} for:memine1231231-2
[18/05/2020 14:09:21 - log] PeerJS:  Received ICE candidates for memine1231231-2: {"candidate":"candidate:1845073376 1 udp 2122257663 2002:89cc:c832::89cc:c832 50068 typ host generation 0 ufrag uEjt network-id 3 network-cost 50","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:21 - log] PeerJS:  Received ICE candidates for memine1231231-2: {"candidate":"candidate:2318809477 1 udp 2122194687 10.0.0.1 50069 typ host generation 0 ufrag uEjt network-id 1","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:21 - log] PeerJS:  Received ICE candidates for memine1231231-2: {"candidate":"candidate:3769299871 1 udp 2122129151 137.204.200.50 50070 typ host generation 0 ufrag uEjt network-id 2","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:21 - log] PeerJS:  Received ICE candidates for memine1231231-2: {"candidate":"candidate:2214029314 1 udp 2122063615 192.168.1.1 50071 typ host generation 0 ufrag uEjt network-id 4","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:21 - log] PeerJS:  Received ICE candidates for memine1231231-2: {"candidate":"candidate:595224848 1 tcp 1518277887 2002:89cc:c832::89cc:c832 9 typ host tcptype active generation 0 ufrag uEjt network-id 3 network-cost 50","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:21 - log] PeerJS:  Received ICE candidates for memine1231231-2: {"candidate":"candidate:3300246901 1 tcp 1518214911 10.0.0.1 9 typ host tcptype active generation 0 ufrag uEjt network-id 1","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:21 - log] PeerJS:  Received ICE candidates for memine1231231-2: {"candidate":"candidate:2921926511 1 tcp 1518149375 137.204.200.50 9 typ host tcptype active generation 0 ufrag uEjt network-id 2","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:21 - log] PeerJS:  Received ICE candidates for memine1231231-2: {"candidate":"candidate:3446969586 1 tcp 1518083839 192.168.1.1 9 typ host tcptype active generation 0 ufrag uEjt network-id 4","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:21 - log] PeerJS:  Server message received: {"type":"ANSWER","src":"memine1231231-2","dst":"memine1231231-1","payload":{"sdp":{"type":"answer","sdp":"v=0\r\no=- 558080532274881943 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\nb=AS:30\r\na=ice-ufrag:iQhi\r\na=ice-pwd:BlAPdu7nho7wU5E3vIz1WRQi\r\na=ice-options:trickle\r\na=fingerprint:sha-256 B2:C3:21:E4:A4:7B:79:EF:A3:6C:56:50:17:C7:B5:DA:6A:2F:03:E6:6D:34:47:C3:5F:A7:25:D0:ED:74:6F:97\r\na=setup:active\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"},"type":"data","connectionId":"dc_7ro8swubsrq","browser":"chrome"}}
[18/05/2020 14:09:21 - log] PeerJS:  Setting remote description {"type":"answer","sdp":"v=0\r\no=- 558080532274881943 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\nb=AS:30\r\na=ice-ufrag:iQhi\r\na=ice-pwd:BlAPdu7nho7wU5E3vIz1WRQi\r\na=ice-options:trickle\r\na=fingerprint:sha-256 B2:C3:21:E4:A4:7B:79:EF:A3:6C:56:50:17:C7:B5:DA:6A:2F:03:E6:6D:34:47:C3:5F:A7:25:D0:ED:74:6F:97\r\na=setup:active\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"}
[18/05/2020 14:09:21 - log] PeerJS:  Server message received: {"type":"CANDIDATE","src":"memine1231231-2","dst":"memine1231231-1","payload":{"candidate":{"candidate":"candidate:589565990 1 udp 2113937151 10.72.113.79 37177 typ host generation 0 ufrag iQhi network-cost 999","sdpMid":"0","sdpMLineIndex":0},"type":"data","connectionId":"dc_7ro8swubsrq"}}
[18/05/2020 14:09:21 - log] PeerJS:  handleCandidate: {"candidate":"candidate:589565990 1 udp 2113937151 10.72.113.79 37177 typ host generation 0 ufrag iQhi network-cost 999","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:21 - log] PeerJS:  Added ICE candidate for:memine1231231-2
[18/05/2020 14:09:21 - log] PeerJS:  Set remoteDescription:ANSWER for:memine1231231-2
[18/05/2020 14:09:21 - log] PeerJS:  Server message received: {"type":"CANDIDATE","src":"memine1231231-2","dst":"memine1231231-1","payload":{"candidate":{"candidate":"candidate:842163049 1 udp 1677729535 151.38.1.95 13467 typ srflx raddr 10.72.113.79 rport 37177 generation 0 ufrag iQhi network-cost 999","sdpMid":"0","sdpMLineIndex":0},"type":"data","connectionId":"dc_7ro8swubsrq"}}
[18/05/2020 14:09:21 - log] PeerJS:  handleCandidate: {"candidate":"candidate:842163049 1 udp 1677729535 151.38.1.95 13467 typ srflx raddr 10.72.113.79 rport 37177 generation 0 ufrag iQhi network-cost 999","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:21 - log] PeerJS:  Added ICE candidate for:memine1231231-2
[18/05/2020 14:09:36 - log] PeerJS:  iceConnectionState changed to disconnected on the connection with memine1231231-2

Logs from B:

[18/05/2020 14:09:12 - log] PeerJS:  Socket open
[18/05/2020 14:09:12 - log] PeerJS:  Server message received: {"type":"OPEN"}
[18/05/2020 14:09:19 - log] PeerJS:  Server message received: {"type":"OFFER","src":"memine1231231-1","dst":"memine1231231-2","payload":{"sdp":{"type":"offer","sdp":"v=0\r\no=- 8597033948884117079 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:uEjt\r\na=ice-pwd:ZC8u2+3M1KWPSYKoTXWsk/WI\r\na=ice-options:trickle\r\na=fingerprint:sha-256 52:10:38:F9:57:64:B0:F0:76:D4:24:87:8E:58:6F:8D:75:0A:84:05:96:64:82:13:93:A2:26:A4:B9:8B:4B:28\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"},"type":"data","connectionId":"dc_7ro8swubsrq","browser":"chrome","label":"dc_7ro8swubsrq","reliable":false,"serialization":"binary"}}
[18/05/2020 14:09:19 - log] PeerJS:  Creating RTCPeerConnection.
[18/05/2020 14:09:19 - log] PeerJS:  Listening for ICE candidates.
[18/05/2020 14:09:19 - log] PeerJS:  Listening for data channel
[18/05/2020 14:09:19 - log] PeerJS:  Listening for remote stream
[18/05/2020 14:09:19 - log] PeerJS:  Setting remote description {"type":"offer","sdp":"v=0\r\no=- 8597033948884117079 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:uEjt\r\na=ice-pwd:ZC8u2+3M1KWPSYKoTXWsk/WI\r\na=ice-options:trickle\r\na=fingerprint:sha-256 52:10:38:F9:57:64:B0:F0:76:D4:24:87:8E:58:6F:8D:75:0A:84:05:96:64:82:13:93:A2:26:A4:B9:8B:4B:28\r\na=setup:actpass\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"}
[18/05/2020 14:09:19 - log] PeerJS:  add connection data:dc_7ro8swubsrq to peerId:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Server message received: {"type":"CANDIDATE","src":"memine1231231-1","dst":"memine1231231-2","payload":{"candidate":{"candidate":"candidate:1845073376 1 udp 2122257663 2002:89cc:c832::89cc:c832 50068 typ host generation 0 ufrag uEjt network-id 3 network-cost 50","sdpMid":"0","sdpMLineIndex":0},"type":"data","connectionId":"dc_7ro8swubsrq"}}
[18/05/2020 14:09:19 - log] PeerJS:  handleCandidate: {"candidate":"candidate:1845073376 1 udp 2122257663 2002:89cc:c832::89cc:c832 50068 typ host generation 0 ufrag uEjt network-id 3 network-cost 50","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:19 - log] PeerJS:  Server message received: {"type":"CANDIDATE","src":"memine1231231-1","dst":"memine1231231-2","payload":{"candidate":{"candidate":"candidate:2318809477 1 udp 2122194687 10.0.0.1 50069 typ host generation 0 ufrag uEjt network-id 1","sdpMid":"0","sdpMLineIndex":0},"type":"data","connectionId":"dc_7ro8swubsrq"}}
[18/05/2020 14:09:19 - log] PeerJS:  handleCandidate: {"candidate":"candidate:2318809477 1 udp 2122194687 10.0.0.1 50069 typ host generation 0 ufrag uEjt network-id 1","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:19 - log] PeerJS:  Server message received: {"type":"CANDIDATE","src":"memine1231231-1","dst":"memine1231231-2","payload":{"candidate":{"candidate":"candidate:3769299871 1 udp 2122129151 137.204.200.50 50070 typ host generation 0 ufrag uEjt network-id 2","sdpMid":"0","sdpMLineIndex":0},"type":"data","connectionId":"dc_7ro8swubsrq"}}
[18/05/2020 14:09:19 - log] PeerJS:  handleCandidate: {"candidate":"candidate:3769299871 1 udp 2122129151 137.204.200.50 50070 typ host generation 0 ufrag uEjt network-id 2","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:19 - log] PeerJS:  Server message received: {"type":"CANDIDATE","src":"memine1231231-1","dst":"memine1231231-2","payload":{"candidate":{"candidate":"candidate:2214029314 1 udp 2122063615 192.168.1.1 50071 typ host generation 0 ufrag uEjt network-id 4","sdpMid":"0","sdpMLineIndex":0},"type":"data","connectionId":"dc_7ro8swubsrq"}}
[18/05/2020 14:09:19 - log] PeerJS:  handleCandidate: {"candidate":"candidate:2214029314 1 udp 2122063615 192.168.1.1 50071 typ host generation 0 ufrag uEjt network-id 4","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:19 - log] PeerJS:  Server message received: {"type":"CANDIDATE","src":"memine1231231-1","dst":"memine1231231-2","payload":{"candidate":{"candidate":"candidate:595224848 1 tcp 1518277887 2002:89cc:c832::89cc:c832 9 typ host tcptype active generation 0 ufrag uEjt network-id 3 network-cost 50","sdpMid":"0","sdpMLineIndex":0},"type":"data","connectionId":"dc_7ro8swubsrq"}}
[18/05/2020 14:09:19 - log] PeerJS:  handleCandidate: {"candidate":"candidate:595224848 1 tcp 1518277887 2002:89cc:c832::89cc:c832 9 typ host tcptype active generation 0 ufrag uEjt network-id 3 network-cost 50","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:19 - log] PeerJS:  Server message received: {"type":"CANDIDATE","src":"memine1231231-1","dst":"memine1231231-2","payload":{"candidate":{"candidate":"candidate:3300246901 1 tcp 1518214911 10.0.0.1 9 typ host tcptype active generation 0 ufrag uEjt network-id 1","sdpMid":"0","sdpMLineIndex":0},"type":"data","connectionId":"dc_7ro8swubsrq"}}
[18/05/2020 14:09:19 - log] PeerJS:  handleCandidate: {"candidate":"candidate:3300246901 1 tcp 1518214911 10.0.0.1 9 typ host tcptype active generation 0 ufrag uEjt network-id 1","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:19 - log] PeerJS:  Server message received: {"type":"CANDIDATE","src":"memine1231231-1","dst":"memine1231231-2","payload":{"candidate":{"candidate":"candidate:2921926511 1 tcp 1518149375 137.204.200.50 9 typ host tcptype active generation 0 ufrag uEjt network-id 2","sdpMid":"0","sdpMLineIndex":0},"type":"data","connectionId":"dc_7ro8swubsrq"}}
[18/05/2020 14:09:19 - log] PeerJS:  handleCandidate: {"candidate":"candidate:2921926511 1 tcp 1518149375 137.204.200.50 9 typ host tcptype active generation 0 ufrag uEjt network-id 2","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:19 - log] PeerJS:  Server message received: {"type":"CANDIDATE","src":"memine1231231-1","dst":"memine1231231-2","payload":{"candidate":{"candidate":"candidate:3446969586 1 tcp 1518083839 192.168.1.1 9 typ host tcptype active generation 0 ufrag uEjt network-id 4","sdpMid":"0","sdpMLineIndex":0},"type":"data","connectionId":"dc_7ro8swubsrq"}}
[18/05/2020 14:09:19 - log] PeerJS:  handleCandidate: {"candidate":"candidate:3446969586 1 tcp 1518083839 192.168.1.1 9 typ host tcptype active generation 0 ufrag uEjt network-id 4","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:19 - log] PeerJS:  Set remoteDescription:OFFER for:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Added ICE candidate for:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Added ICE candidate for:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Added ICE candidate for:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Added ICE candidate for:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Added ICE candidate for:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Added ICE candidate for:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Added ICE candidate for:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Added ICE candidate for:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Created answer.
[18/05/2020 14:09:19 - log] PeerJS:  Set localDescription: {"type":"answer","sdp":"v=0\r\no=- 558080532274881943 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0\r\na=msid-semantic: WMS\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\nb=AS:30\r\na=ice-ufrag:iQhi\r\na=ice-pwd:BlAPdu7nho7wU5E3vIz1WRQi\r\na=ice-options:trickle\r\na=fingerprint:sha-256 B2:C3:21:E4:A4:7B:79:EF:A3:6C:56:50:17:C7:B5:DA:6A:2F:03:E6:6D:34:47:C3:5F:A7:25:D0:ED:74:6F:97\r\na=setup:active\r\na=mid:0\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n"} for:memine1231231-1
[18/05/2020 14:09:19 - log] PeerJS:  Received ICE candidates for memine1231231-1: {"candidate":"candidate:589565990 1 udp 2113937151 10.72.113.79 37177 typ host generation 0 ufrag iQhi network-cost 999","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:19 - log] PeerJS:  Received ICE candidates for memine1231231-1: {"candidate":"candidate:842163049 1 udp 1677729535 151.38.1.95 13467 typ srflx raddr 10.72.113.79 rport 37177 generation 0 ufrag iQhi network-cost 999","sdpMid":"0","sdpMLineIndex":0}
[18/05/2020 14:09:34 - log] PeerJS:  iceConnectionState changed to disconnected on the connection with memine1231231-1

bilo1967 avatar May 18 '20 13:05 bilo1967

Try configuring a TURN server. I had the same problem.

Payetus avatar May 20 '20 15:05 Payetus

Thank you.

The TURN server (coturn) is configured (even if not in the two pages I've put online as an example) and it seems to be working. Trikle Ice says it's ok with relays available. I've also tried with the numb.viagenie.ca TURN server which is widely mentioned on the web with no luck.

May be I've misconfigured something on coturn: if you've configured your own TURN server, can you please post your configuration (except for credentials of course)?

There's one more thing I don't understand. The documentation says that iceCandidates can be added to the configuration as:

config = {
  'iceServers': [
    { url: 'stun:stun.l.google.com:19302' },
    { url: 'turn:0.peerjs.com:3478', username: 'peerjs', credential: 'peerjsp' },
  ]
}

Here I see the've to be added as:

config = {
  'iceServers': [
    { urls: 'stun:stun.l.google.com:19302' },
    { urls: 'turn:0.peerjs.com:3478', username: 'peerjs', credential: 'peerjsp' },
  ]
}

I've obviously tried both but none of them seems to work. BTW, which of the two is correct?

bilo1967 avatar May 20 '20 16:05 bilo1967

0.peerjs.com does not seem to be a public turn server. If you navigate through wiith a browser you should get: image

I use my own TURN server so I cannot post you my configuration for security reasons. I hope you understand.

Try using any of the following:

{ url: 'turn:numb.viagenie.ca', credential: 'muazkh', username: '[email protected]' }, { url: 'turn:192.158.29.39:3478?transport=udp', credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=', username: '28224511:1379330808' }, { url: 'turn:192.158.29.39:3478?transport=tcp', credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=', username: '28224511:1379330808' }, { url: 'turn:turn.bistri.com:80', credential: 'homeo', username: 'homeo' }, { url: 'turn:turn.anyfirewall.com:443?transport=tcp', credential: 'webrtc', username: 'webrtc' }

Payetus avatar May 21 '20 14:05 Payetus

Thank you but nope: they don't work. Or better: they work fost most providers but not for a few.

Are you using CoTurn? In that case, could you please post just the config, without the sensible parts?

bilo1967 avatar May 21 '20 17:05 bilo1967

iceServers = [ { urls: 'turn:turn.uxlandco.com:443', username:'username', credential:'pasword' } ]

El jue., 21 may. 2020 a las 19:42, bilo1967 ([email protected]) escribió:

Thank you but nope: they don't work. Or better: they work fost most providers but not for a few.

Are you using CoTurn? In that case, could you please post just the config, without the sensible parts?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/peers/peerjs/issues/670#issuecomment-632246831, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA47FGZ5DWODNJBFO4NSP2DRSVRX5ANCNFSM4NECCVPA .

Payetus avatar May 22 '20 15:05 Payetus

Thank you. I meant your turnserver.conf. By the way I've found that I had a typo in my peerjs configuration. The correct syntax is

var myPeer = new Peer({
    debug: 3,
    port: 443,
    ... , 
    config: {
        iceServers: [
             { urls: 'turn:server.domain.tld:12345', username: 'xxxx', cretential: 'yyyyy'},
             ...
        ]
    }
});

My iceServers was at the level of the other keys and not inside the config key and it wasn't loaded at all. Now it does and my CoTurn seems fine.

Thank you very much anyway!

bilo1967 avatar May 22 '20 18:05 bilo1967

Hi @bilo1967 I am having same issue and I will need to install a TURN server I guess too... I would have few questions then as you have been passing through that:

  • As soon as you define a TURN server, do all peer connection use it or only the ones failing perviously in your case? (I am asking because I am afraid that in my case if I set up a TURN server and all connection use it to transfer data this may be too much traffic to handle)
  • Have you installed Coturn from there then: https://github.com/coturn/coturn/wiki/turnserver? Thank you Fabrice

tiofabby avatar Jul 03 '20 13:07 tiofabby

As soon as you define a TURN server, do all peer connection use it or only the ones failing perviously in your case?

No. In the iceServers array you'll add your TURN server (even more than one, if you have them) and sone STUN servers too. They can be the free ones from google. PeerJS will first try STUN (which is a very light protocol) and fall to TURN only for those few connections where STUN can't be used.

Have you installed Coturn from there then: https://github.com/coturn/coturn/wiki/turnserver?

No, I found it already packaged for my distro which is quite old. By the way that one from GitHub should easily compile on any recent distro.

bilo1967 avatar Jul 03 '20 15:07 bilo1967

Great, Thanks a lot @bilo1967

tiofabby avatar Jul 03 '20 16:07 tiofabby