question

Brent Batas (Lisk) avatar image
Brent Batas (Lisk) asked

How to get a BuildID from a SessionId?

I'm working on upgrading my dev tools for Servers 2.0.

For calls like ShutdownMultiplayerServer and GetMultiplayerServerDetails

https://docs.microsoft.com/en-us/rest/api/playfab/multiplayer/multiplayerserver/shutdownmultiplayerserver?view=playfab-rest

https://docs.microsoft.com/en-us/rest/api/playfab/multiplayer/multiplayerserver/getmultiplayerserverdetails?view=playfab-rest

Why do we have to provide both the SessionId and the BuildId?

Isn't the SessionId unique? If so, isn't that enough to identify the session?

If there's something I'm missing, then, how can I retrieve the BuildId based on the SessionId?

For full context, I'm trying to create a command for remotely shutting down a server (something we could do in legacy multiplayer with just one button click in the PlayFab dashboard). I want to be able to type something like "shutdown de51953a9107b84e0fce3ad18a7545f8e37ee4b2d0ae38cd5677e02043ab6493" and it will shutdown that instance.

MatchmakingCustom Game Servers
10 |1200

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

Citrus Yan avatar image
Citrus Yan answered

Hi Brent, after a discussion with our team, we draw a conclusion that only the combination of SessionId and BuildId can identify a server session. The reason is that you can request a multiplayer server with the same SessionId on different builds, you can test it by calling RequestMultiplayerServer. So this is the reason why you have to provide both SessionId and BuildId to identify the session.

About retrieving the BuildId based on the SessionId, unfortunately PlayFab does not have such API to be able to do that. You can make a Feature Request about it though. However, we found that buildId and sessionId are both listed in the event “server_state_changed”, maybe you can retrieve those from it although I am afraid it’s hard for you to do it programmatically. Moreover, the amount of buildIds is much lesser compared to sessionIds , maybe you could try to enumerate them. If your sessionIds is random enough then statiscally the chance that you shutdown the wrong server is quite small although this will make many invalid calls.

From my point of view, I think Jason’s approach is quite economic and effective, you can consider about it.

By the way, One more thing that might helpful for you, we can use ListMultiplayerServers to get all server sessions for a build. You can use this to build your tool to shutdown the server instance with a specific session id.

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.

Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

Thanks - I'll be able to come up with a workable solution using ListMultiplayerServers. It was just unintuitive to me that SessionId would be non-unique, given that it has "id" in the name, but it sounds like that's the case.

0 Likes 0 ·
jasonallen avatar image
jasonallen answered

Microsoft::Azure::Gaming::GSDK::getConfigSettings() will give you all the info to make those calls. The dictionary keys can be found in: https://github.com/PlayFab/gsdk/blob/master/cpp/cppsdk/gsdk.h

However this would still need to be done via the server. My server queries the info and then stores it elsewhere so I can see the info whenever I need to make rest calls.

4 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.

Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

Thanks for the reply. Unfortunately I don't think this quite answers the question, because I am looking to call these APIs from a development tool, not from a running server instance.

0 Likes 0 ·
jasonallen avatar image jasonallen Brent Batas (Lisk) commented ·

What I was saying was that my server sends this data after starting up, then I have the info stored for rest calls that I do from dev tools. I think the reason this is required is to stop people from trying brute force rest calls to knock down your server.

0 Likes 0 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) jasonallen commented ·

hmm, I'm still confused :( can you describe your flow a little more specifically? Where do you send information to? Like some persistant data store, like redis or some backend database?

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.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]