Traversal Using Relays around NAT
lastmod 2023-03-07created 2019-02-1318 edits
Traversal Using Relays around NAT (TURN) is a protocol that assists in traversal of network address translators (NAT) or firewalls for multimedia applications. It may be used with the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP). It is most useful for clients on networks masqueraded by symmetric NAT devices. TURN does not aid in running servers on well known ports in the private network through a NAT; it supports the connection of a user behind a NAT to only a single peer, as in telephony, for example.
TURN is specified by RFC 5766. An update to TURN for IPv6 is specified in RFC 6156. The TURN URI scheme is documented in RFC 7065.
A server used to relay traffic when a direct (P2P) connection fails
| INFORMATION |
| The default port is |
About
- When a peer is behind a firewall or proxy, or a direct connection fails for some other reason, the TURN server relays data such as audio/video/data streams in between.
- WebRTC first tries direct UDP communication between peers over the Internet; if that fails, it uses TCP, and if that also fails, it goes through a TURN server. (In practice, though, TCP is rarely used)
- Since it has a public address, it also serves as a STUN server. So it is common to use the TURN server's STUN functionality instead of running a separate STUN server.
TURN relay example
- For a server example, see coturn.
Client javascript:
var config = {
sdpSemantics: "unified-plan",
iceServers: [
{ urls: ["turn:192.168.0.106"], username: "admin", credential: "0000" },
],
iceTransportPolicy: "relay",
iceCandidatePoolSize: "0",
};
var pc = new RTCPeerConnection(config);
Projects
Troubleshooting
stun:localhost is not connect
See Session Traversal Utilities for NAT#stun:localhost is not connect.
See also
- WebRTC
- Session Traversal Utilities for NAT (STUN)
- Traversal Using Relays around NAT (TURN)
- Interactive Connectivity Establishment (ICE)
- Network address translation (NAT)
- UDP hole punching
Favorite site
- Wikipedia (en) Traversal Using Relays around NAT
- WebRTC in the real world: STUN, TURN and signaling
- Understanding STUN, TURN, and ICE
- (WebRTC) About STUN and TURN #1 - Overview
- [Recommended] WebRTC samples Trickle ICE STUN/TURN testing.
- WebRTC: Configure Your Own TURN/STUN Server (red5, TURN, STUN, WebRTC)
- [Recommended] TURN/STUN Server - Red5 Pro Server - Red5 Pro Docs
- [Illustrated] What is WebRTC? (Understanding STUN and TURN servers) (2)