longtoothgames avatar image
longtoothgames asked

Unable to connect to server after specified time, even with existing sessionID

I have an issue where I can’t login to the server after a certain (unknown) amount of time.

Basically, when my (authenticated) client wants to connect to the server, I have an Azure function call that gets the list of servers, if any, and returns them to the client. If the server is active and already has a sessionID, I use the already existing sessionID in my requestMutltiplayerServerRequest to login to the active server. If there is no active server, then I call it with my own generated GUID. This works fine initially.

In testing, I’ll have one client login which causes the server to activate, then I’ll have the second client login using the existing sessionID. I can leave the server, and log back in with either client. However, after a certain amount of time, I start getting the error

“OnRequestMultiplayerError: /MultiplayerServer/RequestMultiplayerServer: MultiplayerServerTooManyRequests - NoHostsAvailableInRegion - No Hosts available in regions 'EastUs', please retry.” I get this message even though I have the active server sessionID.

Nothing has changed and I see nothing in my server logs. I initially thought it might be the server shutting down after I logout from a client, but I kept one client logged in and it remained logged in, even when I could not log in with my second client.

This seems to happen within 20 minutes of activating the server. I’m not sure of the exact time, what’s going on as I get no indication whatsoever that anything has changed. It is, however, consistent. The server even shows Running/Active on the web and as I mentioned, any clients remaining on the server do not get kicked.

The only thing that fixes it is if I bring the server down manually. Then the call from the client spins it up again and everything works for a bit.

The title is C8E30

server log

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

1 Answer

Gosen Gao avatar image
Gosen Gao answered


The current behavior of Multiplayer Server - Request Multiplayer Server - REST API (PlayFab Multiplayer) | Microsoft Docs is by designed, as it is not designed for getting the Active server instance’s info, it is designed to request a new server instance and change the state from standby to active. If you want to get the server instance’s info, please use API Multiplayer Server - Get Multiplayer Server Details - REST API (PlayFab Multiplayer) | Microsoft Docs. BTW, this API has a known issue, we have reported to the team.

10 |1200

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

longtoothgames avatar image longtoothgames commented ·

I think you may have misunderstood my post.

I can get the server details via my Azure function and am able to login to a server that is (recently) active or on standby, it's just after a certain amount of time, I can no longer login even though the server is still active, I have the sessionID, and there are other clients logged in. It's the same call, I get the same (correct) information, but I start getting the above mentioned error after some time passes (less than 20min, not sure of exact time).

It's like something switches and no longer allows new logins, but I don't know what is happening or why.

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao commented ·

What do you mean by "I use that in my requestMutltiplayerServerRequest to login to the active server."? Could you please explain how you login the server, since you only mentioned the SessionId, how do you get the IP and Port?

0 Likes 0 ·
longtoothgames avatar image longtoothgames Gosen Gao commented ·

"I use that in my requestMutltiplayerServerRequest to login to the active server."

By this I mean I use the exisiting sessionID from the active server in my requestMutltiplayerServerRequest as opposed to generating a new one. It is my understanding that if you provide a sessionID from an existing active server, then the the response contains the information from that server.

This works for me. When I test, I have a server on standby, no sessionID. Client 1 requests a server and a new one is spun up using a generated Guid. The server is now active, and client 1 is logged in.

Client 2 then requests server and since there is an active server, it is sent the response containing the active server's information. Client 2 then logs in.

I have an Azure function that gets a list of servers and returns the sessionID of the active server if there is one. This sessionID is then used in the request. The response contains the correct data for the active server (I have tested all of this)

All this works fine. However, after a short period of time (less than 20 min), I can no longer have new clients log in. That is when I get the above mentioned errors.

Thanks for your time

0 Likes 0 ·
longtoothgames avatar image longtoothgames Gosen Gao commented ·

This post explains what I'm doing regarding the existing sessionID.

Edit: so I tried entering the ip and port directly once I start getting the error, and it connects fine. I also tried using the GetMultiplayerServerDetails if the server is active, and RequestMultiplayerServer if not.

Now, the first client activates the standby server and connects, but immediately any other client that tries to connect gets an error from GetMultiplayerServerdetails, which is

"Invalid JSON in request 1-6320c0c1-51cb97d27ebce82d6196c47f ValidationError: Cannot convert null value to Utility.AzureRegion. Path 'Region', line 1, position 47."

The code for calling it is

GetMultiplayerServerDetailsRequest mpRequest = new GetMultiplayerServerDetailsRequest()
                 AuthenticationContext = titleContext,
                 SessionId = sessionID

PlayFabResult<GetMultiplayerServerDetailsResponse> serverDetailsResponse = await PlayFabMultiplayerAPI.GetMultiplayerServerDetailsAsync(mpRequest);
0 Likes 0 ·
Gosen Gao avatar image Gosen Gao longtoothgames commented ·

Sorry for the confusion, I tested this API via Postman. With the latest Unity SDK, this request has already remove "BuildId" and "Region" parameters. I successfully obtained the information of the server by inheriting this Request and defining a new "BuildId" parameter. You can use it as a workaround now, and I will report this issue to the team.

The Unity SDK and C# SDK are different, the C# PlayFab SDK should not be used if there is a more specific SDK that is suited for your project. If you are using Unity, please use Unity SDK.

1 Like 1 ·
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.