Disconnection

Disconnection is what happens when a joining player sends a DISCONNECT message to the host player. This only disconnects the player from the host player; it does not remove the player’s allocation from the Relay server.

Close the connection to the Relay server

For a player to disconnect from a Relay server (that is, remove their allocation from the Relay server), they must send a CLOSE message to the Relay server. The CLOSE message removes the player’s allocation from the Relay server. As a result, players must rebind to the Relay server through the connection flow after closing their connection.

In a typical game session, every player closes their own connection, with the host closing their connection last. Because the host player is the one who created the join code, closing their connection triggers Relay to:

  • Release the host player’s allocation and the join code they created.

  • Terminate the host player’s connection to the Relay server.

When a player closes a connection, the Allocations service updates all connected players to remove the disconnected player. This also frees up a connection slot on the Relay server.

Relay servers might also disconnect players if the connection times out. You can prevent timeouts by keeping the connection alive.

Note: Relay does not provide any method to migrate the host when a host player disconnects from the Relay server through a CLOSE message. However, you can add custom logic to place the remaining players in a lobby and select a new host.