Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Enric Mestre Torrents · Apr 12, 2021 at 02:10 AM · MatchmakingCustom Game Serversmultiplayergame manager

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();
	}
Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by SethDu · Apr 12, 2021 at 09:23 AM

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.

Comment

People who like this

0 Show 4 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Enric Mestre Torrents · Apr 12, 2021 at 10:54 AM 0
Share

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?

avatar image SethDu ♦ Enric Mestre Torrents · Apr 13, 2021 at 06:24 AM 0
Share

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

avatar image Enric Mestre Torrents SethDu ♦ · Apr 15, 2021 at 08:25 AM 0
Share

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?

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    2 People are following this question.

    avatar image avatar image

    Related Questions

    Game match ID system 1 Answer

    Multiplayer Game Server questions. 1 Answer

    Start multiplayer server from cloud script 3 Answers

    How do I get The team ID of a player in Unreal Blueprints after calling GetMatch? 1 Answer

    Matchmaking Flow with Multi-Session Custom Servers 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges