How to use turn server?

690 views Asked by At

I am using xirsys turn server.

Now I want to connect client A which is behind symmetric NAT with client B which is also behind symmetric NAT.

  1. On which port should I listen on client A?
  2. To which ip and port should I connect to establish tcp connection with client A from client B?
  3. How can I obtain the ip of xirsys turn server?

On client A I want to run this command, but I dont know which port should I use:

sudo tcpdump -ni any port ???

On client B I want to run this command, but I dont know which ip and port should I use:

echo "Hello from B" | netcat ip??? port???

PS. The xirsys after executhing this command:

curl -s -H "Content-type: application/json" -XPUT "https://name:[email protected]/_turn/app" -d '{"format": "urls"}'

Return something like this

{
   "s" : "ok",
   "v" : {
      "iceServers" : {
         "credential" : "123",
         "urls" : [
            "stun:eu-turn4.xirsys.com",
            "turn:eu-turn4.xirsys.com:80?transport=udp",
            "turn:eu-turn4.xirsys.com:3478?transport=udp",
            "turn:eu-turn4.xirsys.com:80?transport=tcp",
            "turn:eu-turn4.xirsys.com:3478?transport=tcp",
            "turns:eu-turn4.xirsys.com:443?transport=tcp",
            "turns:eu-turn4.xirsys.com:5349?transport=tcp"
         ],
         "username" : "123"
      }
   }
}
1

There are 1 answers

0
Lee Sylvester On

In a TURN scenario, the two peers are typically labelled Client and Peer, where Client is the instigator of the connection and Peer obeys the data provided by the Client.

When connecting, all data is sent through the TURN server from the Client over the primary port. So, for instance, if the Client uses turn:eu-turn4.xirsys.com:3478?transport=udp as its choice route, then all Client packets will be sent over port 3478.

To establish a connection with the Peer, the Client will request a port Allocation on the TURN server. The Allocation response from the TURN server will contain a newly created port on the server (usually above 16k) known as the Mapped Relay Address. This port should then be communicated to the Peer by the Client (typically over WebSocket signalling) so that the Peer can connect to the TURN server and start receiving / sending packets. The Peers connection is ALWAYS over UDP.

As for the TURN IP; why do you need this? What is your use case?