question

emrys90@gmail.com avatar image
emrys90@gmail.com asked

How to immediately remove server from API

I'm running into an issue where I quit the application on the server when the last player exits, but there's a few seconds delay before its then taken offline in PlayFab. So its still returned in the list of active servers API call and another player could try and connect and fail during those few seconds delay. Does anyone know how I could resolve this?

apis
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sarah Zhang avatar image
Sarah Zhang answered

Between calling the shutdown method and the server state is changed to "Terminate", there will be a process of collecting logs and reclaiming resources. The state transition is designed to be non-immediate. So the ListMultiplayerServers API isn't suitable for such usage. You can consider managing the list of available server sessions on your own.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sarah Zhang avatar image
Sarah Zhang answered

Could you please clarify that how do you allocate the server instances to players? Do you call the API RequestMultiplayerServer on the client? If so, it would be difficult for other players to request the server instance that being shut down. The server instance and the SessionId have a one-to-one correspondence. Only when the players know the specific SessionId of an active serverwill they can get this server’s details via API RequestMultiplayerServer. When players use a new SessionId to request a server via RequestMultiplayerServer, this player can only request a server instance in the standing by server pool. So, typically the delay of server’s shutting down won’t affect the new server’s request.

Besides, as this section -- Gracefully shutting down your game server said, we suggest you perform any necessary cleanup before your application exits. You can close the connection in advance to prevent other players connecting the server when it is being shut down.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

emrys90@gmail.com avatar image emrys90@gmail.com commented ·

I get a list of the servers by using the ListMultiplayerServers API call. It has a couple seconds delay before a server that was shutdown is removed from there. The issue is that returns an inactive server to a client, they try and connect to it, and then the connection fails because that server is offline.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.