About matchmaking from Unity

Hello, we are setting up a dedicated server and we want to use AB matchmaking from Unity. When using a session template with Type: NONE we are able to make the matchmaking work:
Ticket is created, game session is created, a user can find another, etc. No dedicated server on AB involved.

But then if we create a session template with the Type: DS-AMS the matchmaking creates the ticket but nothing else. We can’t get further than that.

More info: we are calling CreateMatchmakingTicket and when it returns successfully we start listening to SessionV2DsStatusChanged:

_lobby.SessionV2DsStatusChanged += result => OnDSStatusUpdatedNotificationReceived(result);

    private void OnDSStatusUpdatedNotificationReceived(Result<SessionV2DsStatusUpdatedNotification> result)
    {
        if (result.IsError)
        {
            // Do something if SessionV2DsStatusChanged fails
            Debug.Log($"Error SessionV2DsStatusChanged, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
        }
        else
        {
            var status = result.Value.session.dsInformation.status;
            if (status == SessionV2DsStatus.AVAILABLE)
            {
                string serverIP = result.Value.session.dsInformation.server.ip;
                Debug.Log($"DS Ready, IP: {serverIP}");
            }
        }
    }

But the method OnDSStatusUpdatedNotificationReceived never gets called. Is this expected behaviour? The dedicated servers are not running yet in AB’s infrastructure, so I’d understand if AB returned some error, but it’s not the case; shouldn’t we get at least some kind of error?

I know you probably need more information, so please feel free to ask!

Thanks!

Hi @xalbertus1,

When using the matchmaking service, _lobby.SessionV2DsStatusChanged will only be updated after a user finds a matching match and the session service requests a DS to AMS. Can you share with us your match rule set and your test case for this testing?

Currently, I’m under the impression that the user has not found a match after creating a match ticket. You can read more about matchmaking here:

  1. Matchmaking in Unity
  2. Matchmaking using ByteWars Unity

Hi! Thanks for the response.

I followed the matchmaking documentation in Unity, but as I am not having any feedback from the service I am kind of lost.

Here is the ruleset:

{
    "auto_backfill": false,
    "alliance": {
        "min_number": 1,
        "max_number": 2,
        "player_min_number": 1,
        "player_max_number": 1
    }
}

As for the test case, it’s very simple:

  1. I call matchmaking.CreateMatchmakingTicket
  2. When the ticket has been created, I register to all of these events:
public void ListenMatchmakingMessages()
    {
        // Match started notification
        _lobby.MatchmakingV2MatchmakingStarted += result => OnMatchmakingStartedNotificationReceived(result);

        // Match found notification
        _lobby.MatchmakingV2MatchFound += result => OnMatchFoundNotificationReceived(result);

        // Match timeout notification
        _lobby.MatchmakingV2TicketExpired += result => OnTimeOutNotificationReceived(result);

        //User invited to gamesession
        _lobby.SessionV2InvitedUserToGameSession += result => OnUserInvitedToGameSessionNotificationReceived(result);

        //user joined gamesession
        _lobby.SessionV2UserJoinedGameSession += result => OnUserJoinedGameSessionNotificationReceived(result);

        //DS Status changed
        _lobby.SessionV2DsStatusChanged += result => OnDSStatusUpdatedNotificationReceived(result);

        // Match canceled notification
        // This feature is still in development and will be added soon
    }
  1. I never find a match or get any messages like match found or timeout or anything at all, even though there’s another person looking for a match with the same config.

I was also trying to follow the Byte Wars tutorials to see if I am missing something, but everything looks simillar to what I am doing.

Let me know if you need more info.

Based on your information, you should be able to find a match instantly since the match requirement is at the minimum of 1 team and 1 player. Therefore, the match-found event should be triggered.

To double-check, have you called the _lobby.Connect()? To receive websocket notifications, you need to connect to it first.

If this still doesn’t resolve your issue, I recommend you try creating a Byte Wars namespace and start using our Byte Wars sample. It will help you verify your configuration.

  1. Create Byte Wars namespace
    image
  2. Configure your IAM clients and your game client and game server SDK configuration.
  3. Game Client
    AccelByteSDKConfig.json
{
    "Default": {
        "Namespace": "<game_namespace_id>",
        "UsePlayerPrefs": true,
        "EnableDebugLog": false,
        "DebugLogFilter": "Log",
        "BaseUrl": "https://<game_namespace_id>.prod.gamingservices.accelbyte.io",
        "RedirectUri": "http://127.0.0.1",
        "PublisherNamespace": ""
    }
}

AccelByteSDKOAuthConfig.json

{
    "Default": {
        "ClientId": "<game_iam_client_id>",
        "ClientSecret": ""
    }
}

More details: Install the AGS Game SDK - Initial setup - (Unity module) | AccelByte Documentation

  1. Game Server
    AccelByteServerSDKConfig.json
{
    "Default": {
        "Namespace": "<game_namespace_id>",
        "PublisherNamespace": "",
        "BaseUrl": "https://<game_namespace_id>.prod.gamingservices.accelbyte.io",
        "RedirectUri": "http://127.0.0.1"
    }
}

AccelByteServerSDKOAuthConfig.json

{
    "Default": {
        "ClientId": "<server_iam_client_id>",
        "ClientSecret": "<server_iam_client_secret>"
    }
}

More details: Set up AMS configuration - Dedicated servers with AccelByte Multiplayer Servers (AMS) - (Unity module) | AccelByte Documentation

Using the bytewars namespace I was able to get as far as getting a “MatchFound” message. I’ve since re-configured our game’s namespace to look like bytewars, however we once again get into a state where no messages come through the lobby connection after creating the matchmaking ticket. The only difference I can currently see is that our session template doesn’t have any requested regions while bytewars has us-east-2. I’m unable to add requested regions to our game’s namespace. Please look through the following and tell us what we’re missing:

image


This can happen when you haven’t activated the region setting in AMS. Please enable the region in the QoS and Fleet region. Then, you will be able to select it in the session template.

Hi @Damar !
We were able to get some messages. Matchmaking ticket was created, then we got SessionV2InvitedUserToGameSession, then we join the session and we got SessionV2UserJoinedGameSession AND MatchmakingV2MatchFound. Why do we get 2 messages? Shouldn’t we get only one of them?

Lastly we get a SessionV2DsStatusChanged message with the error FAILED_TO_REQUEST, which I guess is the expected behaviour as we don’t have the DS running yet.

Hi @xalbertus1,

It depends on your session template configuration. If you enable the Auto-accept session, then you will automatically join the Game Session, receiving two notifications: SessionV2UserJoinedGameSession and MatchmakingV2MatchFound. You can disable the Auto-accept session, and you will only receive MatchmakingV2MatchFound; you will need to join the game session manually. This concept is similar to DoTA matchmaking, where after finding a match, you need to send a ready consent—in this case, manually join the session.

If you have no ready DS, then yes, you will receive FAILED_TO_REQUEST.

Thanks for the reply.
Now we got to join 2 people in the same session but every time a user creates a matchmaking ticket the system creates a session, so in the case we only have 2 players wanting to play we are expecting this:

User 1 creates ticket
There are no sessions, session X is created
User 1 gets invited to session X
User 1 joins session X
User 2 creates ticket
User 2 joins session X
END

But instead we are getting:

User 1 creates ticket
There are no sessions, session X is created
User 1 gets invited to session X
User 1 joins the session X
User 2 creates ticket
Session Y is created even though there’s already a joinable session
User 2 joins session X
Session Y remains as it was when created
END

Is this normal behaviour? I’d expect only 1 session to be created and that both players join it.

Hi @xalbertus1,

That was not normal behavior, User 2 should have joined Session Y, not X. This case is only valid when you do not use a backfill session.

Based on my understanding, you want to implement a backfill session. The backfill session allows users to join existing sessions. You can read more here: Manage backfill tickets using AGS SDK | AccelByte Documentation

@xalbertus1 are both your clients creating their matchmaking ticket at the same time? Or are you saying that User 2 doesn’t create their ticket until User 1 has joined the session?

@Damar assuming that they’re both creating the tickets at the same time, the should both be getting invited to the same session correct?

Our game is 1v1 and therefore doesn’t require backfilling.

However for testing purposes we are using the bytewars template and I believe in this particular case @xalbertus1 is using the unity-elimination-ds-ams pool and therefore the following ruleset:

{
“alliance”: {
“max_number”: 4,
“min_number”: 1,
“player_max_number”: 1,
“player_min_number”: 1
},
“auto_backfill”: true
}

…which now that I’ve pasted it in here doesn’t look correct. player_max_number and player_min_number being equal to 1 means we likely modified the ruleset, which is unexpected in the bytewars namespace. Either way, this ruleset looks to enable a game session with at least 1 team and 4 teams max each of which having 1 player, am I reading that right? And if that’s the case, then we should be able to match 2 clients together.

How long do we have until the matchmaker will decide it can’t create a full game session and therefore create a partially full game session? In this case, how long will it try to create a full game session before deciding that 1 player is good enough?

@njupshot for testing, we were creating a ticket from client1 and when the user had joined a session we were creating a ticket from client2, and that leads to a new session being created even though when the invitation to the client1’s session is received by client2, we join it. I feel like client2 should join the session created by client1 and not create another by itself.

@Damar to clarify, we join the session manually. After being invited to one we call Join session.

Hi @njupshot and @xalbertus1,

To do 1v1 matchmaking, you must use a tight match rule set. For example:

{
  "alliance": {
    "max_number": 2,
    "min_number": 2,
    "player_max_number": 1,
    "player_min_number": 1
  }
}

This will ensure that 2 players will match together, and you will no longer get a session with only 1 player in the game.

@njupshot, a match ticket has an expiration duration. As long as the ticket is active, it will continue searching for a match until it finds a compatible match based on your rule set. If you want to reduce the requirements after x seconds, you can set a flexing match rule. But, if your game was 1v1, there is no reason to tone down the team/player requirement.

For more details on setting up the matchmaking please read here:

  1. Configuring Match Ruleset
  2. Configuring Match Pools

It will help you to set up your matchmaking rule based on your needs.

Thanks a lot! Apparently this is now working client-side :slight_smile:

We have a fleet running and that fleet is launching servers. We are unable to claim one of those servers.

“DSInformation”: {
“Server”: {
“session_id”: “2fe36182a4f44ae99561362b1024d2a7”,
“namespace”: “upshot-bytewars”,
“protocol”: “”,
“provider”: “”,
“game_version”: “”,
“status”: “error claiming DS:unable to claim DS from AMS: unable to request DS for session ID 2fe36182a4f44ae99561362b1024d2a7, namespace upshot-bytewars: no matching DS are available to claim; error message: no matching DS were available: server not found; trace ID: 175d4bbec99e0b5eac91f9c7938e8fcf”,
“last_update”: “0001-01-01T00:00:00Z”,
“deployment”: “”,
“region”: “”,
“is_override_game_version”: false,
“custom_attribute”: “”,
“source”: “”,
“ams_protocol”: null
}

…we’re unable to determine from the documentation or experimentation what would tie the client’s matchmaking request to the fleet other than claim keys. We’ve setup claim keys in the session template to match that of the fleet name. Not sure what else to do here.

I was able to find how you add claim keys to a fleet, the UI doesn’t make this super obvious since you can’t add claim keys under the configure tab which is the most obvious place to search:
image
…but at this point we’re cooking and a DS was claimed!