Implementing our own STUN/TURN server for WebRTC Application [duplicate]
Asked Answered
O

2

36

I am working on a webrtc application and have to implement following TURN server.

https://code.google.com/p/rfc5766-turn-server/

I am following this tutorial.

http://www.dialogic.com/den/developer_forums/f/71/t/10238.aspx

and it says to reference the TURN server as follows, in javascript code where RTCPeerConnection is created.

var pc_config = {"iceServers": [{"url": "stun:stun.l.google.com:19302"},
  {"url":"turn:<turn_server_ip_address>", "username":"my_username", "credential":"my_password"}]};

pc_new = new webkitRTCPeerConnection(pc_config);

I am little confused, why are we referencing to Google's public STUN server. I thought RFC5766 TURN server has STUN inside it.

Is RFC5766 only TURN server? and not STUN server? Can't we implement our own STUN server rather using one provided by Google?

Sorry for such naive question. I am new to WebRTC.

Thanks.

Outnumber answered 6/3, 2014 at 19:22 Comment(0)
D
18

TURN it's an extension of STUN, so TURN server has also STUN features.

https://code.google.com/p/rfc5766-turn-server/ works also as a STUN, so you can try to write something like this:

var pc_config = {
    "iceServers": [{
        "url":"turn:my_username@<turn_server_ip_address>",
        "credential":"my_password"
    }]
};
    
pc_new = new webkitRTCPeerConnection(pc_config);
Drysalt answered 7/3, 2014 at 8:44 Comment(4)
to build our own TURN and STUN server implementation (not using the pre build servers), what would you suggest ?Chorale
@NikhilKinkar I do not recommend to do it since it can take for ages I recommend to use a CoTurn open source server, since it's the most popular server nowDrysalt
@Nikhil Kinkar Have you set up your own TURN and STUN servers?Amie
It's 2022 and you should use github.com/coturn/coturn (it's the updated successor project)Inhalator
B
3

Recently I was capturing my Kurento WebRTC server packets and realized that it has been using this www.stunprotocol.org domain for STUN requests. A tool named stuntman can create a simple STUN server for you.

Just follow these on a Linux host:

  1. sudo apt-get update
  2. sudo apt-get install stuntman-server
  3. stunserver --mode full --primaryinterface 100.101.102.103
    (which the 100.101.102.103 should be replaced by your IP address)
  4. Open This Link to test your STUN server.

e.g. STUN or TURN URI:

stun:100.101.102.103:3478

By this procedure I've mentioned, everything goes well on my machine.

Blame answered 13/11, 2019 at 8:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.