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 in the game session. It doesn't remove the player’s allocation from the Relay server.

Close the connection to the Relay server

For a player to deallocate from a Relay server (remove their allocation from the Relay server), they must send a CLOSE message to 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.
  • End the host player’s connection to the Relay server.

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

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

Note: Relay doesn't have 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. Check out Host migration.