Help With StartMatchmaking (400) Error

0

I'm using flexmatch to connect players for my game in unity. My ruleset, which is on us-west-2, is basically the same as one of the examples, and as follows (called defaultRuleSet).

{
"name": "free-for-all",
"ruleLanguageVersion": "1.0",
"playerAttributes": [{
    "name": "skill",
    "type": "number"
}],
"algorithm": {
    "balancedAttribute": "skill",
    "strategy": "balanced",
    "batchingPreference": "largestPopulation"
},
"teams": [{
    "name": "players",
    "maxPlayers": 200,
    "minPlayers": 30
}],
"rules": [{
    "name": "low-latency",
    "description": "Sets maximum acceptable latency",
    "type": "latency",
    "maxLatency": 150
}],
"expansions": [{
    "target": "rules[low-latency].maxLatency",
    "steps": [{
        "waitTimeSeconds": 12,
        "value": 200
    }],
    "target": "teams[players].minPlayers",
    "steps": [{
        "waitTimeSeconds": 10,
        "value": 20
    }, {
        "waitTimeSeconds": 15,
        "value": 10
    }, {
        "waitTimeSeconds": 20,
        "value": 5
    }]
}]
}

When I attempt to start matchmaking, I get a 400 error. My code is as follows:

public void startMatchMaking()
    {
        ticketId = Guid.NewGuid().ToString();
        inMatchMaking = false;

        AttributeValue skill = new AttributeValue
        {
            N = 1.0
        };

        Player player = new Player
        {
            PlayerId = playerId, //already defined, guid
            LatencyInMs = new Dictionary<string, int>{
                { "us-west-2" , 1 }
            },
            PlayerAttributes = new Dictionary<string, AttributeValue>
            {
                { "skill", skill }
            }
        };

        Debug.Log("Player prepared");
    
        try
        {
            var mmRequest = new StartMatchmakingRequest();
            mmRequest.Players = new List<Player> { player };
            mmRequest.TicketId = ticketId;
            mmRequest.ConfigurationName = "defaultRuleSet";

//algc defined earlier as aglc = new AmazonGameLiftClient(credentials, config);
            StartMatchmakingResponse mmResponse = aglc.StartMatchmaking(mmRequest);

            inMatchMaking = true;
        }
        catch (InvalidRequestException e)
        {
            Debug.Log(e.StatusCode.ToString() + " :( startMatchMaking FAILED. InvalidRequestException " + e.Message);
        }

    }

Am I missing something obvious? What about this request is wrong? Would appreciate help figuring this out. I thought maybe I had to use the internal name (free-for-all), but ding that does not prevent the error.

Thanks!

asked 3 years ago207 views
3 Answers
0
Accepted Answer

[quote="kerg, post:1, topic:9893"] defaultRuleSet [/quote]

Thanks for the help, I found a line I had missed in the logged error which specified that the configuration was wrong - I'd been using the ruleset name and not the config name. Silly of me - working now, thanks.

answered 3 years ago
profile picture
EXPERT
reviewed a month ago
0

Whats the error message you get back?

StartMatchmaking will throw a 400 (according to docs) because:

 InvalidRequestException

    One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.

    HTTP Status Code: 400
NotFoundException

    A service resource associated with the request could not be found. Clients should not retry such requests.

    HTTP Status Code: 400
UnsupportedRegionException

    The requested operation is not supported in the Region specified.

    HTTP Status Code: 400

I would try the obvious:

  • Ensure your request is going to us-west-2 and not a us-east-1 (ie did you set the region in config?)
  • Ensure your matchmaker rule set is actually called defaultRuleSet
  • Ensure your credentials have permission to call StartMatchmaking etc.

Knowing actual error will really help track this down.

answered 3 years ago
0

Just noticed you are catching an InvalidRequestException so it means your passed parameters are wrong.

What does your line Debug.Log(e.StatusCode.ToString() + " :( startMatchMaking FAILED. InvalidRequestException " + e.Message); print?

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions