DEV Community

aprogrammer22
aprogrammer22

Posted on

List of Free Stun and Turn Servers | Open Relay Project

What is a Turn Server?

WebRTC Applications require a server to function for tasks like relaying traffic between peer devices, this is because if the devices are on different networks (As is the case most of the time), a direct socket connection is not possible

The common way to solve this is a TURN server (Traversal Relay NAT) and it is a protocol for relaying traffic.

There are currently several options for TURN servers available online, one of the reliable and free option is the https://openrelayproject.org

Open Relay Project: Free Publicly available TURN Servers?

Provides a free, production ready TURN server to the public.

In the TURN server you need the RTCConfiguration for your client application to use it.

The code snippet below illustrates a sample config for a RTCPeerConnection where server we are using is a free server from the https://openrelayproject.org and the hostnamewe have is openrelay.metered.ca:80 and it is running on port 80.

The configuration object accepts a username nad credentials for secure access to the server.

The OpenRelayProject has provided us with the credentials:

username: "openrelayproject",
credential: "openrelayproject"

const iceConfiguration = {
    iceServers: [
        {
            urls: 'turn:openrelay.metered.ca:80',
            username: 'openrelayproject',
            credentials: 'openrelayproject'
        }
    ]
}

const peerConnection = new RTCPeerConnection(iceConfiguration);
Enter fullscreen mode Exit fullscreen mode

Public Turn Stun Server list

If you need a Public Stun Turn server, the Open Relay project is the Only available free production ready service there is.

You can use the Open relay project in any webRTC application that you are building.

Here are some of the features of the Open Relay Project:
Runs on port 80 and 443

Tested to bypass most firewall rules
Enterprise grade reliability (99.999% uptime)
Support TURNS + SSL to allow connections through deep packet inspection firewalls.
Support STUN
Supports both TCP and UDP
Dynamic routing to the nearest server
Production Ready

What is a STUN Server?

STUN is a set of methods, and a network protocol for transversal of NAT gateways to relay traffic.

STUN is used by other protocols as well such as ICE and SIP and WebRTC.

It lets host devices to discover the presence of NAT and find out the public IP and port number that the NAT has allocated to the UDP to remote hosts.

This protocol requires assistance from a STUN server located in the opposite side of NAT.

Open Relay Project also provides STUN servers along with the Turn servers

STUN is not a self sufficient NAT transversal solution in all the scenarios.

STUN works along with other methods in NAT Transversal most notably TURN Traversal Using Relay NAT and Interactive Connectivity Establishment ICE

STUN works with three types of NAT: full cone NAT, restricted cone NAT and port restricted cone NAT.

STUN does not work with symmetric NAT which is found in most organizations and large enterprises as well as large networks.

This is because the IP address of the STUN server is different from that of the endpoint. In this case TURN server is required.

What is WebRTC?

WebRTC is a technology that enable web applications to exchange video, audio and other data across the internet using a standared set of protocols

Using WebRTC web browsers can also exchange arbitary data without requiring an intermediary.

The set of standards of WebRTC enables people to do video conferencing and data transfers across the web without installing any software.

WebRTC consists of several interconnected protocols which work together to achieve this

What is Signalling?

WebRTC specification includes APIs for communicating with other servers and devices using the ICE Internet Connectivity Establishment Server, but it does not include a way to signal the server.

Signalling is not a part of the WebRTC API and Signalling is required in order to exchange information between devices as to how to connect each other

Signalling can be implemented in many different ways and WebRTC specification does not prefer any single way.

example code for Signalling

const signalingWay = SignalingChannel(remoteClientId);


signalingWay.addEventListner('message', message => {
     cosole.log('message recieved from client', message)
})

Enter fullscreen mode Exit fullscreen mode

Conclusion

If you are building a webRTC application a central requirement is of having a TURN server.

You can creatre your own TURN server but that is expensive and requires a lot of effort

You can also consider OpenRelayProject.Org they provide a free TURN server that is production ready

Top comments (7)

Collapse
 
jcubic profile image
Jakub T. Jankiewicz • Edited

I think that this does not work anymore. My projects stopped working on different networks. It seems that metered.ca require an API key and you need to fetch the ice servers from the server:

var peerConfiguration = {};

(async() => {
  const response = await fetch("https://yourappname.metered.live/api/v1/turn/credentials?apiKey=API_KEY");
  const iceServers = await response.json();
  peerConfiguration.iceServers = iceServers
})();

var myPeerConnection = new RTCPeerConnection(peerConfiguration);
Enter fullscreen mode Exit fullscreen mode

Reference: metered.ca/tools/openrelay/

But note that you still can use it for free, you only need an account and API key.

EDIT:
I just registed and you will also get the list of servers with credential, so you don't need to fetch the list from the servers, unless you need to hide the credentials. You can return it from the server and hide the API key.

Collapse
 
alakkadshaw profile image
alakkadshaw

Hello, The Open Relay Project is running well. You can test the Open Relay Project on the turndemo.metered.ca/

It is just that to prevent abuse you need to create an account to use the TURN server now.

Collapse
 
mannn1ng profile image
Info Comment hidden by post author - thread only accessible via permalink
Isaac Dart

Oh hey, thanks for the article.. just wondering if you know whether OpenRelayProject is still running their free TURN service? It seems to fail using the Trickle Ice tool (not returning any relay ice).. many thanks :)

Collapse
 
aprogrammer22 profile image
aprogrammer22

Hi

Yes it is still running. If you face any problems with regards to the OpenRelayProject you can contact them directly at contact[at]openrelayproject.org

Collapse
 
janaka1984 profile image
janaka1984

why take 45sec to start connections

Collapse
 
docjojo profile image
Chris Ahrweiler

Here is a new tool for STUN/TURN Testing:
icetest.atec-systems.com/

Collapse
 
docjojo profile image
Chris Ahrweiler • Edited

New free STUN server.
freestun.net/

New free TURN server:
freeturn.net/

Some comments may only be visible to logged-in visitors. Sign in to view all comments. Some comments have been hidden by the post's author - find out more