question

whitershores avatar image
whitershores asked

When do active servers shut down with no players?

I've been following the tutorial/samples from: https://github.com/PlayFab/gsdkSamples/tree/master/WindowsRunnerCSharp

I built the official playfab sample, and everything works as intended, the client connects, receives the server configuration info etc.

However, even after I closed the client, the server stays open forever. It just won't shut down at all even with no players connected. If I look at the Session under Multiplayer, it still lists all the players that were created by the client eg 'gamer0', 'gamer1' etc .

Why are these players still in the session even though I physically closed the client, is this normal? Shouldn't the server automatically shut down after a while after the last player disconnects? Otherwise the servers just stay open, using up resources.

PS: Looking at a few other threads like: https://community.playfab.com/questions/40517/is-it-possible-to-unlock-other-regions-with-the-fr.html. This behaviour may be the culprit behind why new developers just trying out your services end up wasting a lot of resources. It may be an idea to fix the code if it is buggy, or add some warnings at least.

support
10 |1200

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

brendan avatar image
brendan answered

Servers cannot all be shut down when there aren't any players unless you (as the developer) explicitly turn off the region. If there are no servers running your build, the next time someone tries to join a game session, they have to wait for a server to be provisioned, then for the game server build to be downloaded to that server and decompressed, then for the build to start. That takes on the order of minutes, which player's aren't going to wait through. The only way a player can join a server with second-level delay is if there's an active server running your code.

During development, you need to disable any regions you have active, for the servers to turn off. This is detailed in our documentation, but in particular I would recommend reviewing the build region lifecycle: https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/servers/multiplayer-build-region-lifecycle

The issue of a no-longer running session showing as active would be separate, and something we should check, if you can provide a repro. If you see a server build in this state, please let us know the specifics (Title ID, session, PlayFab IDs of the players).

10 |1200

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

whitershores avatar image
whitershores answered

@Brendan

I can confirm that setting a region's max and standby servers to 0, does not shut down the servers for at least 24 hours.

You should be able to reproduce this bug easily. Build the official Playfab C# Server/client apps from:

https://github.com/PlayFab/gsdkSamples/tree/master/WindowsRunnerCSharp

Register a new free tier account, upload the server, deploy it with 1 standby and 1 max servers. Then connect with the client so that a session is created, then close the client. Then set both the standby/max servers to 0.

The server may eventually shut down at some point, but for at least 24 hours it will be both shown as active and the VM instance hours will keep increasing, running up unwanted charges with no way of shutting it down other than brute force deleting the build. I cannot imagine this being the intended behaviour.

6 comments
10 |1200

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

brendan avatar image brendan commented ·

Thanks, we've got a bug open on this. For now, please be sure to completely turn off any region where you don't want running servers by removing the configuration.

0 Likes 0 ·
brendan avatar image brendan commented ·

Actually, upon investigation, the build did go to 0 standby servers immediately. If you have a look at the concurrent servers graph in the Game Manager, you'll see that standby dropped to 0 - the issue was that the running VM was still reporting that it had an active session (note that Active Servers remained at 1, while Standby Servers dropped to 0). We're not sure why your server was reporting that it was still Active, but it was shut down a day later.

0 Likes 0 ·
whitershores avatar image whitershores commented ·

@Brendan

Yes the standbys go to 0 and the Active remains at 1. The problem is that it is not only reported as active, but that the VM instance hours keep ticking up and accumulating chargeable hours...

0 Likes 0 ·
brendan avatar image brendan whitershores commented ·

Servers are active until they exit - that's controlled by the server code. What is the logic for when the server exits its loop and shuts down?

0 Likes 0 ·
whitershores avatar image whitershores brendan commented ·

@Brendan , I was using your own server example from:

https://github.com/PlayFab/gsdkSamples/blob/master/WindowsRunnerCSharp/WindowsRunnerCSharp/Program.cs

I thought that had all the logic required. Is there anything else I need to do to ensure the server exits and is properly shut down?

0 Likes 0 ·
Show more comments

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.