I'm using the latest 5.1.2 version of the GameLift server SDK for C# and observing a buggy behavior in the SDK: Upon having a client connect, my server receives the player session ID from the client, which it uses as argument to GameLiftServerSDK.AcceptPlayerSession("psess-....")
. I would expect that the method would only succeed for valid player sessions with state RESERVED
and only for player sessions that are registered for the specific server's game session. However, it turns out that the method always returns successful, also for expired player session IDs, or for completely invalid ones (random strings). In the server logs, it is visible that the method returns successfully before GameLift APIs respond with the actual response, i.e. the game server accepts the client before receiving the actual response from GameLift (which seems to be discarded?).
Here's a snippet of the log from my GameLift-hosted server instance:
456214 [Thread Pool Worker] DEBUG Aws.GameLift.Server.ServerState (null) - Reporting health using the OnHealthCheck callback.
456214 [Thread Pool Worker] INFO Aws.GameLift.Server.ServerState (null) - Received TRUE from the onHealthCheck callback. Reporting process as healthy.
456218 [Thread Pool Worker] INFO Aws.GameLift.Server.GameLiftWebSocket (null) - Sending message to GameLift: {"HealthStatus":true,"Action":"HeartbeatServerProcess","RequestId":"4313deab-a463-4b94-9ade-d20ada387360"}
456266 [Thread Pool Worker] INFO Aws.GameLift.Server.GameLiftWebSocket (null) - Received HeartbeatServerProcess for GameLift with status 200. Data: {"Action":"HeartbeatServerProcess","RequestId":"4313deab-a463-4b94-9ade-d20ada387360","StatusCode":200}
Game Server: On client connected (connection index 0)
Game Server: Sending auth request to client (connection index 0)
Game Server: Received auth response from client (connection index 0)
Game Server: - GameLift player session id: psess-fafb96c8-1451-4868-8efd-2c425805ad34
483833 [1] INFO Aws.GameLift.Server.GameLiftWebSocket (null) - Sending message to GameLift: {"GameSessionId":"arn:aws:gamelift:eu-west-1::gamesession/fleet-fe149927-5e37-458f-a957-8b050b7f76bf/gsess-b6fcb2bb-18a8-499f-aae8-806beb0231b5","PlayerSessionId":"psess-fafb96c8-1451-4868-8efd-2c425805ad34","Action":"AcceptPlayerSession","RequestId":"819cd0c6-25e1-44f8-b948-cc00c50fb547"}
Game Server: GameLiftServerSDK.AcceptPlayerSession() successful (connection index 0)
483893 [Thread Pool Worker] INFO Aws.GameLift.Server.GameLiftWebSocket (null) - Received AcceptPlayerSession for GameLift with status 200. Data: {"Action":"AcceptPlayerSession","RequestId":"819cd0c6-25e1-44f8-b948-cc00c50fb547","StatusCode":200}
483893 [Thread Pool Worker] DEBUG Aws.GameLift.Server.GameLiftWebSocketRequestHandler (null) - Request 819cd0c6-25e1-44f8-b948-cc00c50fb547 already removed.
483893 [Thread Pool Worker] DEBUG Aws.GameLift.Server.GameLiftWebSocketRequestHandler (null) - No promise found for request 819cd0c6-25e1-44f8-b948-cc00c50fb547.
Game Server: On client disconnected (connection index 0)
493246 [1] INFO Aws.GameLift.Server.GameLiftWebSocket (null) - Sending message to GameLift: {"GameSessionId":"arn:aws:gamelift:eu-west-1::gamesession/fleet-fe149927-5e37-458f-a957-8b050b7f76bf/gsess-b6fcb2bb-18a8-499f-aae8-806beb0231b5","PlayerSessionId":"psess-fafb96c8-1451-4868-8efd-2c425805ad34","Action":"RemovePlayerSession","RequestId":"e8777286-65dd-44d1-9179-1f3d9529321a"}
493303 [Thread Pool Worker] INFO Aws.GameLift.Server.GameLiftWebSocket (null) - Received RemovePlayerSession for GameLift with status 200. Data: {"Action":"RemovePlayerSession","RequestId":"e8777286-65dd-44d1-9179-1f3d9529321a","StatusCode":200}
493303 [Thread Pool Worker] DEBUG Aws.GameLift.Server.GameLiftWebSocketRequestHandler (null) - Request e8777286-65dd-44d1-9179-1f3d9529321a already removed.
493303 [Thread Pool Worker] DEBUG Aws.GameLift.Server.GameLiftWebSocketRequestHandler (null) - No promise found for request e8777286-65dd-44d1-9179-1f3d9529321a.
Game Server: On client connected (connection index 1)
Game Server: Sending auth request to client (connection index 1)
Game Server: Received auth response from client (connection index 1)
Game Server: - GameLift player session id: psess-fafb96c8-1451-4868-8efd-2c425805ad34
494760 [1] INFO Aws.GameLift.Server.GameLiftWebSocket (null) - Sending message to GameLift: {"GameSessionId":"arn:aws:gamelift:eu-west-1::gamesession/fleet-fe149927-5e37-458f-a957-8b050b7f76bf/gsess-b6fcb2bb-18a8-499f-aae8-806beb0231b5","PlayerSessionId":"psess-fafb96c8-1451-4868-8efd-2c425805ad34","Action":"AcceptPlayerSession","RequestId":"278c1c6f-d6da-4fcc-87d3-95cb12aa4ef4"}
Game Server: GameLiftServerSDK.AcceptPlayerSession() successful (connection index 1)
494815 [Thread Pool Worker] INFO Aws.GameLift.Server.GameLiftWebSocket (null) - Received AcceptPlayerSession for GameLift with status 400. Data: {"Action":"AcceptPlayerSession","RequestId":"278c1c6f-d6da-4fcc-87d3-95cb12aa4ef4","StatusCode":400,"ErrorMessage":"InvalidPlayerSessionStatusException: PlayerSession (fafb96c8-1451-4868-8efd-2c425805ad34) has a status of COMPLETED instead of RESERVED"}
494815 [Thread Pool Worker] WARN Aws.GameLift.Server.GameLiftWebSocket (null) - Received unsuccessful status code 400 for request 278c1c6f-d6da-4fcc-87d3-95cb12aa4ef4 with message 'InvalidPlayerSessionStatusException: PlayerSession (fafb96c8-1451-4868-8efd-2c425805ad34) has a status of COMPLETED instead of RESERVED'
494816 [Thread Pool Worker] DEBUG Aws.GameLift.Server.GameLiftWebSocketRequestHandler (null) - Request 278c1c6f-d6da-4fcc-87d3-95cb12aa4ef4 already removed.
494816 [Thread Pool Worker] DEBUG Aws.GameLift.Server.GameLiftWebSocketRequestHandler (null) - No promise found for request 278c1c6f-d6da-4fcc-87d3-95cb12aa4ef4.
Game Server: On client disconnected (connection index 1)
In the log you can see two subsequent client connections. Both are authenticated successfully, despite the second one is using an outdated player session. GameLift event logs the faulty response (status code 400) but still returns true
from AcceptPlayerSession()
.
I've seen 2 old posts (3 and 5 years old) of similar reports, and wondered if this is still a standing issue?
Hi Oswaldo. What you describe is what I would expect, too. However, the
GameLiftServerSDK.ActivatePlayerSession()
method does not fail with anInvalidPlayerSessionStatusException
, even when being called with a completed, timed-out, or outright invalid player session ID, but instead completes successfully. From what I can tell, this feels like a bug in the API, and from my logs it seems that the method is even returning before the API request completes (hence not knowing the result of the API request). So, in theory I agree that your described flow sounds correct. In practice (AWS GameLift Server SDK 5.1.2), this does not behave as expected, as I would expect the method to return a failure based on the API response, so that my server code can rely on GameLift's response when validating new player connections.