Is there an event for game session termination?

I’m trying to migrate my current dedicated server from playfab to gamelift, and Playfab had an event for session closing, that I could catch in cloud code. I’ve used this to handle reconnecting of players who had some network issues/crashing.
So far I’ve found nothing similar in gamelift. Is there a way to get an event out to lambda or SNS every time a game session closes (for any reason, ended, crashed, terminated, all need to be caught)?

Thank you!

1 Like

When calling InitSDK in your server, it takes in a parameter of type ProcessParameters, which takes in a handler function called onProcessTerminate that I believe fits your needs in this situation. For more info, check GameLift server API reference for C++: Data types - Amazon GameLift

Thank you for your answer, but it doesn’t fit my need. In case of process crashing, it cannot catch it.
The gamelift service itself knows when a game is terminated, because it can gather logs, and upload them on s3, I believe, so I was wondering if there is an event there I could catch.


Would also like to know if there’s an event similar to the FlexMatch or placement events that can trigger when a game session is terminated. Currently we’re invoking a lambda on termination from the game script, but crashes are indeed a problem. We’re currently tracking our player’s status (playing/idle), and if a player is attempting an API call (for example, start matchmaking) when they’re already in playing state, we’re polling gamelift via describe player session to see if it shows as terminated and if it is, then we’re assuming that the gamescript has crashed

Hi @Robert_Demjan and @zakyg ,

Sorry for the late reply. GameLift logs process abnormal termination in fleet events (accessible via DescribeFleetEvents, e.g. SERVER_PROCESS_CRASHED, see doc for a full list of fleet events. NOTE that there is a typo for 'Server process events" as it currently says “Spot process events”. I just cut a ticket to fix that. #16834)

So, you can poll DescribeFleetEvent to see whether game session has crashed. Hopefully this suffices your use case in the short term. We currently do not offer fleet events in SNS, but this has been requested in the past and is being tracked in our backlog.


1 Like

Thanks for the reply!

Using the other API polling calls is discouraged, is that similar for this one? Is there a limit on the frequency of calling DescribeFleetEvent?

@Robert_Demjan , maybe a global rejection / exception handler would be good for this use case?

process.on(‘uncaughtException’, function(error) {

process.on(‘unhandledRejection’, function(reason, p){

Using the other API polling calls is discouraged, is that similar for this one?

That would be the case if there is a better alternative using push. Also, different from DescribeMatchmaking, DescribeGameSessionPlacement or DescribeGameSession, (which are the 3 APIs that customers incorrectly poll the most) which are not scalable to poll because you’d hit a bottleneck beyond a certain point as your game grows. However, since there is only limited number of fleet regardless of how large your game is, polling DescribeFleetEvent is reasonably scalable.