question

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

What would cause SessionIdKey to be missing from GameserverSDK.getConfigSettings()?

My previously working code is now suddenly broken. I get a KeyNotFoundException when trying to get the SessionId on a server.

My code looks like this:

string titleId = GameserverSDK.getConfigSettings()[GameserverSDK.TitleIdKey];
DeveloperApi.LogToText("titleId was: " + titleId);

int port = GameserverSDK.GetGameServerConnectionInfo().GamePortsConfiguration.First().ClientConnectionPort;
DeveloperApi.LogToText("Port was: " + port);

string sessionId = GameserverSDK.getConfigSettings()[GameserverSDK.SessionIdKey]; // <--- this line errors with KeyNotFoundException
DeveloperApi.LogToText("Session id was: " + sessionId);

The titleId prints correctly (B186).

The port prints as 0 (which sounds incorrect?)

The sessionId errors because it can't seem to find the key GameserverSDK.SessionIdKey (which is simply 'sessionId')

MockVMAgent looks like this:

https://i.imgur.com/nJ3qk2e.png

Why is this happening and what can I do to fix it?

Custom Game Servers
2 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.

Sarah Zhang avatar image Sarah Zhang commented ·

I will test it on our test project. I'm wondering could you please tell me is your server exe a c# server, a Unity server or others?

1 Like 1 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) Sarah Zhang commented ·

Hi Sarah, sorry I forgot to specify! It's a C# console application.

0 Likes 0 ·
Sarah Zhang avatar image
Sarah Zhang answered

SessionCookieKey, SessionIdKey, these two keys are only available after allocation (once readyForPlayers returns true). I'm wondering if you tried to get them after allocation.

You can find this info here.

10 |1200

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

Daniel avatar image
Daniel answered
@Sarah Zhang

What about "game_port" key? Is it also available only after the allocation?
I am trying to get the game_port from the client but for some reason it returns weird port number "30005" whereas the game_port I previously set in the build settings is 8080. Do you have any idea why it behaves like that? Thanks in advance.

10 |1200

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

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.