question

Enric Mestre Torrents avatar image
Enric Mestre Torrents asked

How can I connect players to the game server?

Hi, I'm new to Playfab and to multiplayer in general. I'm working on an online mobile game that must have a lot of users online in the same server. I've followed different tutorials and I've managed to create a custom server and a matchmaking queue. The problem is that when I try to use RequestMultiplayerServerRequest API I get stucked in waiting for server response. If I try to skip the matchmaking and connect directly to the server I get this error :

MultiplayerServerNotFound - DeploymentNotFoundForRegion - Deployment(s) {xxxxxx} was not found in any of the regions specified - {NorthEurope}

I've checked my Game Manager and I've specified the server region.

Can someone tell me what I'm doing wrong? My ID is 1B3AF

public class Matckmaking : MonoBehaviour
{
	const string queueName = "DefaultQueue";
	string ticketId;
	[SerializeField]
	Text debugText;
	[SerializeField]
	GameObject playButton;
	Coroutine pollCoroutine;
    public void CreateMatchmaking()
	{
		PlayFabMultiplayerAPI.CreateMatchmakingTicket
		(
			new CreateMatchmakingTicketRequest
			{
				Creator = new MatchmakingPlayer
				{
					Entity = new EntityKey
					{
						Id = PlayFabManager.EntityId,
						Type = "title_player_account"
					},
					Attributes = new MatchmakingPlayerAttributes
					{
						DataObject =  new 
						{
							latencies = new object[]
                            {
                                new {
                                    region = "NorthEurope",
                                    latency = 150
                                }
							}
						}
					}
				},
				GiveUpAfterSeconds = 120,


				QueueName = queueName
			},
			OnMatchmakingTicketCreated,
			OnMatchmakingTicketError
		);
		Debug.Log("Creating Request");
	}
	void OnMatchmakingTicketCreated(CreateMatchmakingTicketResult result)
	{
		Debug.Log("Entering");
		ticketId = result.TicketId;
		debugText.text = "Ticket Created";
		playButton.SetActive(false);
		pollCoroutine = StartCoroutine(PollTicket());
	}
	void OnMatchmakingTicketError(PlayFabError error)
	{
		Debug.Log(error.GenerateErrorReport());
	}
	IEnumerator PollTicket()
	{
		while(true)
		{
			PlayFabMultiplayerAPI.GetMatchmakingTicket
			(
				new GetMatchmakingTicketRequest
				{
					TicketId = ticketId,
					QueueName = queueName
				},
				OnGetMatckmakingTicket,
				OnMatchmakingTicketError
			);
			yield return new WaitForSeconds(6.0f);
		}
	}


	void OnGetMatckmakingTicket(GetMatchmakingTicketResult result)
	{
		debugText.text = "Status: " + result.Status;


		switch(result.Status)
		{
			case "Matched":
				StopCoroutine(PollTicket());
				StartMatch(result.MatchId);
				break;
			case "Canceled":
				StopCoroutine(PollTicket());
				playButton.SetActive(true);
				break;
		}
	}
	public void StartMatch(string id)
	{
		debugText.text = "Starting Match";
		PlayFabMultiplayerAPI.GetMatch
		(
			new GetMatchRequest
			{
				MatchId = id,
				QueueName = queueName
			},
			OnGetMatch,
			OnMatchmakingTicketError
		);
	}
	void OnGetMatch(GetMatchResult result)
	{
		Debug.Log(result);
		Debug.Log(result.ServerDetails);
		Debug.Log(result.ServerDetails.IPV4Address);
		Debug.Log(result.ServerDetails.Ports);
		Debug.Log(result.ServerDetails.Region);
		debugText.text = $"{result.Members[0].Entity.Id} vs {result.Members[1].Entity.Id}";
		GetComponent<PlayFabManager>().ConnectToServer();
	}
MatchmakingCustom Game Serversmultiplayergame manager
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

·
Seth Du avatar image
Seth Du answered

Since you are still developing the project, I assume you haven’t increased the quota of your multiplayer server, have you? How many Maximum servers and Standby servers have you configured in your title? You may need to shut down the running instances to release the server resources back to the pool.

Have you enabled auto-allocation for the matchmaking queue?

PS. PlayFab provide 750 single core hours for each title per month and there are 24 Dasv4 cores available in both East US and North Europe. Concurrent running instances will use up the core hours fast. Hence, we suggest testing single instance at a time at the very beginning of development.

Recently we also notice that there is partial degradation on Multiplayer Server service at Apr 12. The team are continuing to investigate this issue. It should be fixed soon. Please tell us if you are still able to reproduce this issue.

Please subscribe PlayFab Status to get the latest update.

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

Enric Mestre Torrents avatar image Enric Mestre Torrents commented ·

First of all thank you for your replay, reading your response I can see that the problem with not being able to connect to the server relies on having not shut down the instances. How can you do so?

Answering the other question; yes I have enabled auto-allocation for the matchmaking queue but I still get stucked with the status waiting for server. Any idea of what I'm missing?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Enric Mestre Torrents commented ·

>>To shut down Multiplayer Server instance

Usually, we recommend checking connected players routinely on the server build. If there are no connected players for a specified time or the match is ended, the server build can run Application.Quit() or any other quit command to exit. As long as there is no heartbeat from GSDK, the instance will be shut down soon.

Otherwise, you may call ShutdownMultiplayerServer API externally to manually shut down the instance.

>>enabled auto-allocation for the matchmaking queue

Basically, it will be like automatically call RequestMultiplayerServer after a match is found. The behavior is the same. "Waiting for server" usually means there is no available servers.

0 Likes 0 ·
Enric Mestre Torrents avatar image Enric Mestre Torrents Seth Du ♦ commented ·

Following your advice I've created an application.quit method to shutdown the server. I've successfully managed to pair two players in the matchmaking but I'm hitting the same error. My debug console looks like this:

/MultiplayerServer/RequestMultiplayerServer: MultiplayerServerTooManyRequests - NoHostsAvailableInRegion - No Hosts available in regions 'NorthEurope', please retry.

I don't understand why I have this error because I have more than one server available at all times. Is it because I'm requesting a server with both clients? If so, how should I do it?

0 Likes 0 ·
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.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]