JsonSerializationException: Required property 'ip' not found in JSON. Path '', line 8, position 1.

When trying to allocate a server from my script I’m faced with this error and for some reason it returns null when I try to read the ServerConfig. This is the script please help.

public class MatchmakerServer : MonoBehaviour
{

public event Action? OnServerStart;

async void Start()
{
OnServerStart += MatchmakerManager_OnServerStart;

await UnityServices.InitializeAsync();

StartCoroutine(StartServer());
}
async Awaitable StartServer()
{
var Server = MultiplayService.Instance.ServerConfig.ToString();

Debug.Log($“Server: {Server}”);

var transport = NetworkManager.Singleton.GetComponent();

Debug.Log("Network Address: " + transport.ConnectionData.Address + "Network Port: " + transport.ConnectionData.Port);

OnServerStart.Invoke();

var callbacks = new MultiplayEventCallbacks();

callbacks.Allocate += Callbacks_Allocate;

callbacks.Deallocate += Callbacks_Deallocate;

callbacks.Error += Callbacks_Error;

while (MultiplayService.Instance == null)
{
await Awaitable.NextFrameAsync();
}

}

private void Callbacks_Error(MultiplayError obj)
{
Debug.LogError(“Multipllay Service Callback error”);
}

private async void Callbacks_Deallocate(MultiplayDeallocation obj)
{
Debug.Log($“Service Deallocating:{obj}”);

await MultiplayService.Instance.UnreadyServerAsync();
}

private async void Callbacks_Allocate(MultiplayAllocation obj)
{
Debug.Log($“Servive Allocating: {obj}”);

await MultiplayService.Instance.ReadyServerForPlayersAsync();
}

private void MatchmakerManager_OnServerStart()
{
NetworkManager.Singleton.SceneManager.LoadScene(“Main Project”, LoadSceneMode.Single);
}
}

2 Likes

I’m having the same problem when writing anything with “MultiplayService.Instance”. Is there anything I have to do before hand?

Having this issue as well. Bump

Try creating a “server.json” file in the same folder where this script is

Hi,

The Multiplay allocation relies on the environment provided by Multiplay (the Server Query Protocol server, server events, readiness, the server.json file, … to name a few). It is not currently supported neither locally, nor in editor.
The recommended way to allocate a Multiplay server is through Matchmaker: when players have been found and a match is created, a server is automatically started with the build you uploaded to Multiplay. The server.json file is automatically injected by Multiplay so the SDK can find it when allocating.

Please have a look at our Multiplayer SDK Multiplay Hosting support documentation for the code server-side.
Client side, Matchmaking into a session will be more relevant.