Hello,
im currently having a problem when using netcode for gameobjects and matchmaker. A few weeks ago everything was working fine and i could connect to the server. But suddenly it stopped working. After investigating i found the error. In the OnAllocate function
m_MultiplayEventCallbacks = new MultiplayEventCallbacks();
m_MultiplayEventCallbacks.Allocate += OnAllocate;
i try to get the result of the allocation with
string payload = MultiplayService.Instance.GetPayloadAllocationAsPlainText().Result;
I added a debug.log before and after this statement. The server reaches the first debug.log but never the second. So that means it is stuck at this statement. After that i added a for loop that logs the status of the task
for (int i = 0; i < 1000; i++)
{
Debug.Log(test.Status);
System.Threading.Thread.Sleep(100);
if (test.IsCompleted)
{
payload = test.Result;
i = 100000;
}
}
It prints: WaitingForActivation
I tried to rearrange the order of the initialization options but it did not work. After removing this statement everything went on fine and crashed later, because the payload was empty which is perfectly fine, because my game needs this information.
I do the following things:
if (UnityServices.State == ServicesInitializationState.Uninitialized)
await UnityServices.InitializeAsync();
m_MultiplayEventCallbacks = new MultiplayEventCallbacks();
m_MultiplayEventCallbacks.Allocate += OnAllocate;
m_MultiplayEventCallbacks.Deallocate += OnDeallocate;
m_MultiplayEventCallbacks.Error += OnError;
m_MultiplayEventCallbacks.SubscriptionStateChanged += OnSubscriptionStateChanged;
m_ServerEvents = await MultiplayService.Instance.SubscribeToServerEventsAsync(m_MultiplayEventCallbacks);
NetworkManager.Singleton.NetworkConfig.ConnectionApproval = true;
NetworkManager.Singleton.ConnectionApprovalCallback += OnConnectionApprovalCallback;
NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnectCallback;
NetworkManager.Singleton.OnClientDisconnectCallback += OnClientDisconnectCallback;
m_ServerQueryHandler = await MultiplayService.Instance.StartServerQueryHandlerAsync(UnityNetworkData.DEFAULT_MAX_PLAYERS, UnityNetworkData.DEFAULT_SERVER_NAME, UnityNetworkData.DEFAULT_GAME_TYPE, UnityNetworkData.DEFAULT_BUILD_ID, UnityNetworkData.DEFAULT_MAP);
ServerConfig serverConfig = MultiplayService.Instance.ServerConfig;
if (serverConfig.AllocationId == "") return;
NetworkManager.Singleton.GetComponent<Unity.Netcode.Transports.UTP.UnityTransport>().SetConnectionData("0.0.0.0", serverConfig.Port, "0.0.0.0");
NetworkManager.Singleton.StartServer()
Is there anything missing, am i doing something wrong or has something changed i don’t know about?
Thank you for your help.