As we all know, WebRTC is used for video communication.
In video communication, data packets are transferred from one place to another place, therefore a user is able to see other user’s streaming.
But sometimes, when there are some network securities like firewall, then data packet does not transfer and we do not get proper streaming of another user i.e. we get black screen as other user’s stream.
So for this solution, we use turn server.
The TURN Server is a VoIP media traffic NAT traversal server and gateway. It can be used as a general-purpose network traffic TURN server and gateway, too.
Here, I am going to explain you the steps of installing and configuring turn server on Amazon EC2.
First of all download these 2 packages :
libevent-2.0.21-stable.tar.gz (http://libevent.org/)
turnserver-2.6.5.2.tar.gz (https://code.google.com/p/rfc5766-turn-server/downloads/list)
then run these commands :
1. To install libevent package
$ tar xvfz libevent-2.0.21-stable.tar.gz
$ cd libevent-2.0.21-stable
$ ./configure
$ make
$ sudo make install
2. To install turn server
$ tar xvfz turnserver-2.6.5.2.tar.gz
$ cd turnserver-2.6.5.2
$ ./configure
$ make
$ sudo make install
Idconfig command to create, update, and remove the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/usr/lib, /lib64 and /lib).
3. $ ldconfig
4. In your Javascript code where the RTCPeerConnection is created, reference the TURN server as follows:
var pc_config = {“iceServers”: [{“url”: “stun:stun.l.google.com:19302”}, {“url”:”turn:my_username@’amazon ec2 PUBLIC ip address’ “, “credential”:”my_password”}]};
pc_new = new webkitRTCPeerConnection(pc_config);
5. Open the following ports:
TCP 443
TCP 3478-3479
TCP 32355-65535
UDP 3478-3479
UDP 32355-65535
6. then run this command from turnserver-2.6.5.2 folder to start the turn server
$ sudo turnserver –syslog -a -L ‘amazon ec2 PRIVATE ip address’ -X ‘amazon ec2 PUBLIC ip address’ -E ‘amazon ec2 PRIVATE ip address’ -f –min-port=32355 –max-port=65535 –user=’my_username’:’my_password’ -r realm –log-file=stdout -v
Hi,
I am trying to do the same, however running into some problems. Firstly, what do you mean by the amazon ec2 PUBLIC/PRIVATE ip address ? I believe my amazon ec2 isnt behind any NAT per se given i can directly ssh into it. How do I go about knowing the private address ?
Also, whats the use of the username/password/realm ?
Thanks a ton
Hi Harry
For Public/Private IP address: Just go to Amazon EC2 instance -> Select the instance and then you will get all the information of that instance below. Then you will get there Public IPs and Private IPs section.
Username/password : As you will see that whatever the username and password we are giving in command , the same we are providing in JavaScript in step 4.. So to authenticate user, we provide these values.
Hi,
Iam trying to run the turnserver on AMAZON EC2 instance but it says ..
UDP/DTLS listener opened on: 10.xxx.xx.136:3478
but its not the public ip its private ip .
Is it work even though it displays that message i did all you said above no errors and warnings
am I don’t need to specify any port along with the ip address in JavaScipt code
No, we have no need to specify port along with IP in javascript
Thank u so much its working for me now Great Article
hi, following the instructions everything seems to work. But the remote video appears as a black square.
Looking at the logs on turn server, we can see this result:
2291: handle_udp_packet: New UDP endpoint: local addr 10.244.153.152:3478, remote addr 177.97.88.27:50435
2291: user : incoming packet BINDING processed, success
2292: user : incoming packet BINDING processed, success
2292: handle_udp_packet: New UDP endpoint: local addr 10.244.153.152:3478, remote addr 189.68.215.31:59145
2292: user : incoming packet BINDING processed, success
2292: user : incoming packet BINDING processed, success
2292: user : incoming packet BINDING processed, success
some ideas?
thanks in advance
HI,
Sorry, I did not face this type of problem.
It will be better , if you ask this question on Turn server Google group https://groups.google.com/forum/?hl=en#!forum/turn-server-project-rfc5766-turn-server
hi, when running step number 6, does the IP’S username and password need to be between quotation marks? ‘xxx-xxx-xxx-xxx’
No, you should provide these values without quotation marks.i.e. xxx-xxx-xxx-xxx
Can you give me samples how to use my Turn server. Also give me some test case how to check my turn server if its working correctly. Thanks in advance!
sudo turnserver -syslog -a -L ‘xx.xx.xx.xx’ -X ‘yy.yy.yy.yy’ -E ‘xx.xx.xx.xx’ -f –min-port=32355 –max-port=65535 –user=’userName’:’password’ –realm –log-file=stdout -v –max-bps=20000 –no-stun
give as it is and replace xx.xx.xx.xx and yy.yy.yy.yy read documentation for better understanding and to test check calls between 2 countries or any secured network or restricted access location
….. Hope this helps
i need to mention that yy.yy.yy.yy is public ip address
xx.xx.xx.xx is your private not local this is exist only when u r under NAT or AWS EC2
Wheb you say username and password, do you mean we need to configure an account in the turbuserdb.conf file ? Or are we using the aws credentials ?
sudo turnserver -syslog -a -L ‘xx.xx.xx.xx’ -X ‘yy.yy.yy.yy’ -E ‘xx.xx.xx.xx’ -f –min-port=32355 –max-port=65535 –user=’userName’:’password’ –realm –log-file=stdout -v –max-bps=20000 –no-stun
the above command itself says USERNAME and PASSWORD
Great Article, but what is the -r realm? is realm the value we should pass or do we make it up? does aws provide this value? the docs around it are confusing. do you have any examples?
When you will read “README.turnserver” file inside the turnserver package, then you will find the explanation for the same.
It says :
“Realm to be used for all users. Must be used with long-term credentials mechanism or with TURN REST API.”
ok Thank you, I got it to work! one remark, I believe that “–min-rt=32355” is misspelled and should be “–min-port=32355”. most people probably figure it out, but it is a pretty crucial step for the tutorial.
Ohh.. I didn’t notice this. Thanks for pointing out the mistake. I have corrected that.
I asked before, but I am not sure the comment posted. anyways, What should the realm value be? where do I get this value, or should I literally just pass the word realm?
Thanks
Reblogged this on Play!ng with Scala.
Reblogged this on dotnetask.
Can you explain each parameter in this line {“url”:”turn:my_username@’amazon ec2 PUBLIC ip address’ “, “credential”:”my_password”} ? I am struck and do not know how to move forward.
For my_username and my_password : These are the values which we are passing in step 6. These 2 should be same.
amazon ec2 PUBLIC ip address : this is your amazon EC2’s public IP address
Thank You Sir. Can you help me accessing RTC from two different networks? I am running a browser client app and an Android app where both the are connected in the same network. It works fine.
When change browser and Android app to different networks they do not work. I do not know how use my Amazon Turn server to rectify this problem. Please help me.
How do I open TCP ports (Step 5)?
I am not getting any debugging lines in TURN server console.
Sir, I am not getting any debug messages in my Amazon Linux console. Can you help me?
Hi,
This is a great article. It was a great help but I wanted to know what are the minimum configuration(ram,cpu) required to run the turn server?.. I want my turn server to handle 20 concurrent audio only webrtc calls.
Thankyou
Do I need to do anything with /etc/turnserver.conf file before following your steps? I have been struggling to get your steps done. Please guide me.
Hello,
Thank you very much for simplification of TURN server installation.
I have started my TURN server on EC2. And my Node.js server for WebRTC is also on same instance. When I am trying to make call from Wifi, it’s getting connected but when I am trying from 4G or 3G network it’s showing black screen.
I red some of your solutions and tried as well but non of them helped. Tell me one more thing how you made your EC2 instance as public as you mentioned here in this link ( Link: https://stackoverflow.com/questions/37270782/turn-server-in-ubuntu-is-not-working)
Thanks,
Sachin
Hi Sachin,
First thing, As you mentioned above, I have not mentioned anything in the given link: https://stackoverflow.com/questions/37270782/turn-server-in-ubuntu-is-not-working. This link does not belong to me.
Second, If you are talking about public IP pf EC2, then note one thing we don’t make the instances as public. EC2 instance contains 2 IPs by its own, public and private. So As i read in the given link, it is talking about public IP of ec2 instance.
Hi Rishi,
I agree that, the link which I mentioned does not belongs to you, but I was trying to give an context of my problem. sorry for it.
But I am facing similar kind of problem.
I am aware about Public and Private IP of my EC2 instance. but if you read this answer (Link: http://stackoverflow.com/a/37406704/5997793) you will get to know why I get confused about making instance public.
Can you please ping me on my gmail id?
sachinmutthe@gmail.com
Thanks,
Sachin.
Reblogged this on Rishi Khandelwal.
if we are using this turnserver guaded by above then we dont need to pay any cost. Means on our amazon instance we can install turnserver. Also there is any space matter if more user calling at the same time, means bandwidth issue etc
CONFIGURATION ALERT Unknown argument: – ;;
this error is coming when i run the above command
-opntion
Hi Rishi,
We are using turnserver version 4.5.0.5, but your command of turnserver doesn’t work. there is error reads not known command ––max-port=65535, and our local can’t reach AWS EC2 container, could you please help? we are using port 80 instead of 3478.
Hi albert.gu, change –max-port=65535 for –max-port 65535 same thing for –min-port