Hello, I’m implementing the server readiness on my server hosted on game server hosting, but I may don’t understand how this feature works.
I set the server readiness tick in build configuration and then I triggered the allocation via API. This is a sample result that I always get.
{
"allocationId": "f14ad29d-3993-4fde-a0fe-b168220d1c8f",
"buildConfigurationId": ********,
"created": "2024-07-02T07:25:11.487Z",
"fleetId": "***********",
"fulfilled": "2024-07-02T07:25:11Z",
"gamePort": 9100,
"ipv4": "*********",
"ipv6": "",
"machineId": 8066766,
"readiness": true,
"regionId": "81c45693-feb0-4380-b940-d149574cf63e",
"requestId": "5140dd42-5c86-4927-b5ec-2eb3673ca7a1",
"requested": "2024-07-02T07:25:11Z",
"serverId": 72814851
}
So allocation request is right, but the readiness parameter is always true.
Here’s what I tried in server code:
- I tried to not call ReadyServerForPlayersAsync at all in server code.
- I tried to call it in Allocation event callback after a delay of 10 seconds so I can see if anything change before and after the call of the ReadyServerForPlayersAsync function, nothing changed, readiness is always true.
- I tried to call UnreadyServerForPlayersAsync in Awake function before all initialization and in allocate callback, result still the same
For me setting the readiness disabled on the dahsboard worked fine, then when server starts i set is to enable with “await MultiplayService.Instance.ReadyServerForPlayersAsync();”
Hey, I just wanted to add some more context to this question 
When you have readiness enabled for your game server, as mentioned above, you must ReadyServerForPlayersAsync:
await MultiplayService.Instance.ReadyServerForPlayersAsync();
This will notify that the server has initialized and is ready to accept players, games that do not use the readiness flag will automatically be set to ready to accept players, but you should use the readiness flag if you need to do any ‘warming up’ or initializations of the server prior to players connecting.
You should review the flow chart available from the Server Readiness documentation, as this shows when readiness should be set and how it interacts with allocations
See an example of an OnAllocate flow in the following snippet:
private static void OnAllocate(MultiplayAllocation alloc)
{
var config = MultiplayService.Instance.ServerConfig;
var configIp = config.IpAddress;
var ipv4Address = "0.0.0.0";
var port = config.Port;
NetworkManager.Singleton.GetComponent<UnityTransport>().SetConnectionData(ipv4Address, port, "0.0.0.0");
StartDedicatedServer();
SetServerReady();
}
private static void StartDedicatedServer()
{
NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnected;
NetworkManager.Singleton.OnClientDisconnectCallback += OnClientDisconnect;
NetworkManager.Singleton.StartServer();
}
private static async void SetServerReady()
{
await MultiplayService.Instance.ReadyServerForPlayersAsync();
}