Unity Relay (Beta)

Note: Unity Relay (including this documentation) is currently in beta release, and that by using Unity Relay you agree that you have read and agree to the Terms of Service.
Warning: Do not use Relay in COPPA flagged games.

Unity Relay offers a way for game developers to securely provide increased connectivity between players by using a join codeA simple, randomly generated code that allows connecting players to join a host player's game. style workflow without needing to invest in a third-party solution. The Relay service enables developers to connect players together using a listen server. Instead of using dedicated game serversA game server hosted on a remote machine that multiple players can connect to by using a game client. (DGS), the Relay service provides connectivity through a universal Relay server acting as a proxy.

The Relay service has two key components: the Relay servers and the Relay Allocations service.

Note: During the open beta release, turning off Relay for a project also turns off Lobby if both services are enabled.

Relay servers

The Relay service facilitates multiplayer support without dedicated game servers by allowing players to communicate with each other through Relay servers. The Relay servers deliver messages between connected playersAn end-user connected to a game client that wants to play in a game match. In Relay, each player has a unique identifier within the current game session. Because players can only communicate with other players within the same session, there are no globally unique player identifiers.. No two players ever connect directly to each other; all communication goes through a Relay server.

Relay servers act as public endpoints reachable by all players, which addresses common issues of changing networks and IP addresses, network address translation (NAT), and firewalls between players. Each player can connect to the same IP address and port (the selected Relay server’s IP), and game clientsClients, or game clients, are executable programs that players use to play a game. In multiplayer games, clients allow players to connect to other players to participate in a game match. Game clients using the Relay service should facilitate players joining a game session by using a Relay server. can trust that the connection information remains the same throughout the game sessionIn the Relay service, a game session is an active match between multiple players connected through a Relay server. One player is the host player to which the other connecting players communicate using the Relay message protocol.. Through this indirection, players in a game match do not need to be aware of each other's IP address, thereby increasing security and privacy. See Relay servers, Players, Clients, Scaling, and Join codes.

A diagram showing how players send all messages through the Relay server

Allocations service

The Allocations service works on the backend to enable playersAn end-user connected to a game client that wants to play in a game match. In Relay, each player has a unique identifier within the current game session. Because players can only communicate with other players within the same session, there are no globally unique player identifiers. to create and join matches. It serves the entry point for interacting with the Relay service. It exposes a public-facing API that allows players to allocate a slot on a Relay server. Players can then use the allocated Relay server to communicate with other players. See Allocations service, Networking, Authentication, and Connection flow.

Dependencies and requirements

The open beta release of the Relay service comes coupled with the Unity Transport Package (UTP). Relay enhances Transport (UTP) and gives it the ability to connect clients that would otherwise be unable to communicate because of routing restrictions such as restrictive firewalls.

Limitations

During the open beta release, Relay has the following limitations:

Fair usage

The Relay service is intended for the transmission of multiplayer game state only. Usage of the service outside this category is subject to rate limiting or termination under terms of service.

Unfair use of the Relay service includes, but is not limited to, the following examples:

  • Audio streaming of any nature, including voice chat

  • Video streaming of any nature

  • File transfer services

  • Distributed computation unrelated to gameplay, including crypto mining

  • General network proxying and other VPN-like services