GetPlayerConnectionDetails - Amazon GameLift Servers

GetPlayerConnectionDetails

This API works with the following fleet types: EC2 (server SDK 5.x or later), Container

Retrieves connection details for game clients to connect to game sessions.

Player gateway benefits: DDoS protection with negligible impact to latency.

To enable player gateway on your fleet, set PlayerGatewayMode to ENABLED or REQUIRED when calling CreateFleet or CreateContainerFleet.

How to use: After creating a game session and adding players, call this operation with the game session ID and player IDs. When player gateway is enabled, the response includes connection endpoints and player gateway tokens that your game clients can use to connect to the game session through player gateway. To learn more about player gateway integration, see DDoS protection with Amazon GameLift Servers player gateway.

When player gateway is disabled or in locations where player gateway is not supported, this operation returns game server connection information without player gateway tokens, so that your game clients directly connect to the game server endpoint.

Request Syntax

{ "GameSessionId": "string", "PlayerIds": [ "string" ] }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

Note

In the following list, the required parameters are described first.

GameSessionId

A unique identifier for the game session for which to retrieve player connection details.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 512.

Pattern: [a-zA-Z0-9:/-]+

Required: Yes

PlayerIds

List of unique identifiers for players. Connection details are returned for each player in this list.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 25 items.

Length Constraints: Minimum length of 1. Maximum length of 1024.

Required: Yes

Response Syntax

{ "GameSessionId": "string", "PlayerConnectionDetails": [ { "Endpoints": [ { "IpAddress": "string", "Port": number } ], "Expiration": number, "PlayerGatewayToken": "string", "PlayerId": "string" } ] }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

GameSessionId

A unique identifier for the game session for which the player connection details were retrieved.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 512.

Pattern: [a-zA-Z0-9:/-]+

PlayerConnectionDetails

A collection of player connection detail objects, one for each requested player.

Type: Array of PlayerConnectionDetail objects

Array Members: Minimum number of 1 item.

Errors

For information about the errors that are common to all actions, see Common Errors.

InternalServiceException

The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.

HTTP Status Code: 500

InvalidGameSessionStatusException

The requested operation would cause a conflict with the current state of a resource associated with the request and/or the game instance. Resolve the conflict before retrying.

HTTP Status Code: 400

InvalidRequestException

One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.

HTTP Status Code: 400

LimitExceededException

The requested operation would cause the resource to exceed the allowed service limit. Resolve the issue before retrying.

HTTP Status Code: 400

NotFoundException

The requested resources was not found. The resource was either not created yet or deleted.

HTTP Status Code: 400

UnauthorizedException

The client failed authentication. Clients should not retry such requests.

HTTP Status Code: 400

UnsupportedRegionException

The requested operation is not supported in the Region specified.

HTTP Status Code: 400

Examples

Get player connection details with player gateway enabled

This example retrieves connection details for a game client to connect to a game session through player gateway.

Sample Request

{ "GameSessionId": "arn:aws:gamelift:ap-northeast-2::gamesession/fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa/gsess-4444dddd-55ee-66ff-77aa-8888bbbb99cc", "PlayerIds": ["player1"] }

Sample Response

{ "GameSessionId": "arn:aws:gamelift:ap-northeast-2::gamesession/fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa/gsess-4444dddd-55ee-66ff-77aa-8888bbbb99cc", "PlayerConnectionDetails": [ { "PlayerId": "player1", "Endpoints": [ { "IpAddress": "192.0.2.0", "Port": 7777 }, { "IpAddress": "198.51.100.0", "Port": 7777 }, { "IpAddress": "203.0.113.0", "Port": 7777 } ], "PlayerGatewayToken": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "Expiration": "1736365885.22" } ] }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: