Google is committed to advancing racial equity for Black communities.
See how.
TURN server
For most WebRTC applications to function a server is required for relaying the
traffic between peers, since a direct socket is often not possible between the
clients (unless they reside on the same local network). The common way to solve
this is by using a TURN server. The term stands for Traversal Using Relays
around NAT, and it is a protocol for relaying network traffic.
There are currently several options for TURN servers available online, both as
self-hosted applications (like the open-source COTURN project) and as cloud
provided services.
Once you have a TURN server available online, all you need is the correct
RTCConfiguration
for your client application to use it. The following code
snippet illustrates a sample configuration for a RTCPeerConnection
where the
TURN server has the hostname my-turn-server.mycompany.com
and is running on
port 19403
. The configuration object also support the username
and
credential
properties for securing the access to the server. These are
required when connecting to a TURN server.
const iceConfiguration = {
iceServers: [
{
urls: 'turn:my-turn-server.mycompany.com:19403',
username: 'optional-username',
credential: 'auth-token'
}
]
}
const peerConnection = new RTCPeerConnection(iceConfiguration);
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-05-04 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2023-05-04 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-05-04 UTC."],[],[]]