question

lukaskebel avatar image
lukaskebel asked

How to get Player Stats for Servers while using Photon & Playfab

We deployed a few servers with Playfab Multiplayer and tested them. From the Game Site (which is created with Unity) The servers can be seen online and they can be seen in Playfab, too with the corresponding Session ID.


But, the second the servers restart the Session ID is gone. It is not shown in Playfab anymore while the server is shown without a session ID. Also there are no Player stats available. I think this is because the Players are using Matchmaking and Rooms from the Photon Multiplayer Service.


How can i get the Data to Playfab?

Why do we lose the Session ID, after a server restarts?

windows
21.png (45.0 KiB)
10 |1200

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

Xiao Zha avatar image
Xiao Zha answered

>> How can i get the Data to Playfab?

If by “get the Data to PlayFab” you mean get the connected player’s data when server is active, you can follow the documentation: Integrating game servers with the PlayFab Game Server SDK (GSDK) - PlayFab | Microsoft Learn to maintain a list of connected players in your server, then you can call Get Multiplayer Server Details API to get the connected player Ids, then use the player Id to obtain the player data you want.

>> Why do we lose the Session ID, after a server restarts?

The Session ID is set between the StandingBy state and the Active state, and can only be obtained when the server is currently active.

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.

lukaskebel avatar image lukaskebel commented ·

The Problem is that we are using Photon in the background. Photon Multiplayer uses a Room and Lobby Based System and it was possible to transfer some Player Data to Playfab via Webhooks in the past but this option is depricated. Now there are the Azure Functions but nothing to be found how to get to the same result as with the webhooks.

0 Likes 0 ·
lukaskebel avatar image
lukaskebel answered

we used Integrate Unity with GSDK for this purpose but it didn't work. At least we don't get any Player DATA on the running server but instead afterwards in Playfab Game Manager we have the statistical Data in the Player Tab.

10 |1200

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

lukaskebel avatar image
lukaskebel answered

i did found one culprit. Right now our Server Build ist restarting automatically when a session ends. This seems to lead to serval Problem. First of, it does not get a new Session ID when restarted but uses the same Session ID again and that doesn't work and leads to some strange issues. The Server is also not archived at the end of the session, although the Server Shutdown call is done in the build. When i do it manually from the outside it is archived.

So instead i think we have to update the lifecycle of the server in a way it does only restart (and do so with a new session ID) each time it gets an specific API call.

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.

Xiao Zha avatar image Xiao Zha commented ·

When your game session ends, MPS will delete the container/process running this game server and collect, upload game logs and create a new container/process in its place to replace the terminated container/process, then remain on standby status until be used. And when the new server instance in standby status, there should be no session id. So, how are you requesting the server after the new server instance occurs? If it is automatically allocated through the matchmaking queue, then the sessionId is the MatchId, and each match ID should be different. If you call the RequestMultiplayerServer API to request the Server, the sessionId needs to be set by yourself. If the session ID is not changed every time the server is requested, then the sessionId should be the same.

In addition, since you mentioned that the Server Shutdown call is done in the build, but no logs are archived. Have you implemented the PlayFabMultiplayerAgentAPI.OnShutDownCallback? You can refer to our MPS samples: GitHub - PlayFab/MpsSamples . You can also refer to : MpsSamples/Debugging.md at main PlayFab/MpsSamples GitHub to debug your game server.

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.