What am I doing wrong using Flexmatch and SNS?

Greetings,

so far, I managed to create game sessions, search them, join them, but this all happens manually by providing an Alias.

The last step now would be to do that automatically via Flexmatch, thus using a Queue additionally.

So I dug my way through ‘the whole’ documentation, set up a queue, a rule set, a configuration and even a sns topic (which is linked in my configuration), because no one likes polling if it can be avoided :slight_smile:

The thing is, I call StartMatchmaking (like I called all the other “Async”-methods before (like CreateGameSession, DescribeGameSession, …)) but here I am pretty stuck. It looks like the call returns succesfully, but no GameSession is created, nor do I have a clue, how and where the SNS Topic is handled. So far I didn’t set up a Subscription (is it necessary?), nor did I code anything SNS-specifically.

My gut says that I’m stuck around here, but at this point I’m at my wits end and seek for help.

Kind regards

Edit: Checking the Console’s Dashboard it looks like the matchmaking is indeed succesful and Tickets get created, but no one is listening (so I guess my problem is SNS-specific. I try to read more about it, but so far I pretty much don’t get it). Or do I need an Lamba function as well? If so, I’m confused by this line in the documentation * “There are two options for setting up event notifications. You can use Amazon CloudWatch
Events, which has
a suite of tools available for managing events and taking action on them. Alternatively,
you
can set up your own SNS topic(s) and attach them to your matchmaker to receive matchmaking
event notifications directly.”*

Hi @BZ_PSU,

I am sorry you are having this problem!

Your SNS topic is for you (your game server) to receive events from Matchmaking. Game sessions should get placed automatically once matches are successfully formed.

Here are some preliminary ideas, but I will need more information in order to understand exactly what is going wrong:

  • the match is not actually being created because it does not have the minimum number of players, as defined by your matchmaking rule set

  • the queue is not correctly pointing to your fleet/alias
    In order to investigate this further, can you provide any of the following information:

  • your fleet id or alias

  • your queue name

  • your matchmaking configuration name

  • the ticket ids you are passing into StartMatchmaking
    Thank you!

Hi @RoundCat,

thank you for your answer, as I am not at home at the moment, the fleet is not active currently, but I will provide you with everything I can access.

Alias: alias-60bdddd5-ec28-4b93-9dfe-78225d3b02ae

Queue Name: SoloRankedEuCentralQueue

Matchmaking Confugration Name: SoloRankedEuCentralMatchmakingConfiguration

and the Tickets are partly generated randomly, so maybe that is already one mistake I`m doing. I´m not sure about the correctness of my rule set or the queue, but it should be fine as I set the alias in my queue and followed (hopefully) the documentation about the rule set. But yeah. I can´t rule those out.

Fur testing purposes only 1 player against another player should be set for now.

Again. Thanks for any help.

Hi @RoundCat,

Thanks for the quick reply. I’m pretty sure that I tried that out as first thing (because that is the one thing I want to accomplish), but I didnt get a GameSessionArn back from the succesful call of the second matchmaking. I think I had like up to three players looking and then I got confused about a part in the docs about the Tickets. I was not sure if every searching player needs to know about the others ticket ids, which seems contradictionary to me.

So assuming, queue, config and alias is correct: when I call StartMatchmaking with a locally, randomly genrated id. That is correct, right? And if another client does excatly that, with its own Ticketid, that should work? Or am I wrong?

I’ll try that as soon as I get home on sunday, but I’m quite sure that I didn’t receice a GameSessionArn to join.

Which brings me to another question. How does the first (or any) Client get an Event if a Gamesession was created? I’m asking this, because the call of StartMatchmaking is succesful even though there is no second Client yet. (I guess here is what I’m doing wrong?)

Sorry for any typos, not a talented writer on my phone.

Hi @BZ_PSU,

From the data I pulled up, it looks like you are making calls to StartMatchmaking with only one player each time. These will be timing out because no other player is added to the match, so the 1v1 match cannot be formed.

Can you try making 2 calls to StartMatchmaking in quick succession? That should result in a match, and you should see events from the matchmaker doing its work appear in your SNS topic.

Also, it looks like you currently have no fleets active, as you said. When you spin up a new fleet, make sure to match it to your alias. The flow is something like:

Matchmaking Configuration defines Queue --> Queue has Alias as a destination --> Alias points to Fleet.

Finally, randomly generated ticket Ids should be fine. I think the problem is not enough players being sent to matchmaking.

Hi @RoundCat,

so thanks for pointing that out. Stupid copy-paste mistake of mine. I fixed it and will try it out tonight.

“Have you looked at your topic in the AWS console and not seen any notifications of events?”

I really don’t know where. Every tab is empty. I guess something is missing?

A call to StartMatchmaking just inputs a player or a set of players on a matchmaking ticket into the matchmaking system. This call will succeed if the input is valid but at this point, there is no guarantee of a match being successfully created and a game session placed.

“So assuming, queue, config and alias is correct: when I call StartMatchmaking with a locally, randomly genrated id. That is correct, right? And if another client does excatly that, with its own Ticketid, that should work? Or am I wrong?”

You are not wrong. https://docs.aws.amazon.com/gamelift/latest/apireference/API_StartMatchmaking.html

Every searching player does NOT need to know of others - that is the job of the matchmaking system.

When a game session is placed, you should get the notification on your SNS topic (or you can check for it by calling DescribeMatchmaking).

In this case, a game session is never placed because a match is never created. The player tickets go into the matchmaking system and time out without finding a match.

If you try this more on Sunday, can you notify me of the time of your tests?

I’m about to start one try in the next few minutes, where I will just call StartMatchmaking from multiple clients.

“When a game session is placed, you should get the notification on your SNS topic (or you can check for it by calling DescribeMatchmaking).”

This may sound stupid, but where do I get this notification?

If nothing happens today I can go for a try with DescribeMatchmaking and see what happens, but I’d like to handle this as the documentation is suggesting (not before 30s passed)

Edit: The current fleet id is

fleet-8a27adb2-d488-4a5d-9fd3-ff99a6753f5a

due to pricing I will shut it down later.

Edit2: Tried it today with DescribeMatchmaking and received no GameSessionArns (which is not a big surprise, considering that not GameSessions gets created). I don’t know if offline fleet-ids help you, but this was the fleet.

fleet-21f39ef3-e56a-4ebe-a4b6-0f93e4d4fd60

I gues it all boils down to “where do I get the SNS topic notification?” and/or why is no GameSession created even though 2 tickets are open (maybe my rule set/match config is messed up.)

Hi @BZ_PSU,

I see your tickets all time out (and I see 3 tickets from your most recent test). Firstly, your SNS topic should have notifications of timed out matchmaking tickets, they were all sent on 03/31 between 16:06 and 16:09 UTC. Have you looked at your topic in the AWS console and not seen any notifications of events?

Secondly, matches are indeed never created. In your rule set, you have:

    "teams": [{

“name”: “red”,
“maxPlayers”: 1,
“minPlayers”: 1
}, {
“name”: “blue”,
“maxPlayers”: 1,
“minPlayers”: 1

But the rule for team sizes is:

    {

“name”: “EqualTeamSizes”,
“description”: “Only launch a game when the number of players in each team matches, e.g. 4v4, 5v5, 6v6, 7v7, 8v8”,
“type”: “comparison”,
“measurements”: [ “count(teams[cowboys].players)” ],
“referenceValue”: “count(teams[aliens].players)”,
“operation”: “=” // other operations: !=, <, <=, >, >=

The problem is that the teams “cowboys” and “aliens” are not defined - the teams defined are “red” and “blue”. Can you change these to match and see if that will work?

Totally understand shutting down fleets due to costs. I actually don’t need the fleet to be up in order to look at what matchmaking did.

Hi @BZ_PSU,

I think I see what the problem is. You need to create a subscription to the SNS topic in order to receive the notifications. I believe an SQS queue subscribed to your topic will be able to display the notifications.

Check out the SNS documentation for how to get started: https://docs.aws.amazon.com/sns/latest/dg/sns-getting-started.html

And let us know when you try again, if you are able to successfully get a game session placed.

Also, can you edit your post and remove the screenshot? I got everything I needed from that.

Hey!

That’s great! You got a match created!

I think your client needs to use that SQS queue and process the notifications as they come in.

You can join PlayerSessions to a GameSession using the GameSessionId - each game session placed will have a unique ID. See the documentation here: https://docs.aws.amazon.com/gamelift/latest/developerguide/game-sessions-intro.html and here: https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-sdk-client-api.html (section “Join a Player to a Game Session”).

Hope that helps, let me know if you need anything else!

Hi @RoundCat,

And in order to use that SQS queue in need to implement the SDK as plugin to UE4 and it is not already in the GameLiftServerSDK or any other Plugin-ready SDK out there, right?

Yeah I get GameSessions, PlayerSessions and Players join those sessions already running, but so far they join with IP+Port which is always the same, and one server instance doesn’t know about other server instances and their port (or IP). So I have to figure out how I am able to start multiple server instances with different ports and how Players get assigned to those different instances. Atleast custom ports are the only thing I can find concerning UE4 and multiple server instances.

Edit: Another question (I hope, I’m not being a nuisance): So SNS is able to send messages to another service like SQS (and more), but not to the client directly? I’m just asking this, because it looks redundant to me.

Hi @RoundCat,

It worked! Thank you very much! I really appreciate it!

This fleet did it: fleet-0fa3472f-db77-4015-85b8-f1c0194c13ce

To be able to finalize everything (and don’t use dirty workarounds) a few questions remain now:

How do I get the SNS Topic notify my UE4 client? So far I set up the SQS queue to see the messages in the console.

In
UE4 I join the Server via IP, how will I be able to join specific GameSessions if they all share the same IP? (I have the feeling I got that covered already and forgot about it… as this is pretty important and basic)

  1. As far as I am aware, yes, to use SQS you need to use the AWS SQS SDK. And I don’t think your client needs these notifications, they are more for a centralized system to handle.

Either way, I found this: https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/1445918-ue4-to-aws-lambda-and-other-aws-service-integration

  1. You are able to specify the number of server processes running on one instance of your fleet. See here: https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-creating.html

I am not sure what you mean by “they join with IP+Port”, since GameLift has APIs to connect players to a game session using the session ID, as I have linked in my previous post.

  1. SNS is able to send messages to any endpoint set up to receive them. https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html - you would not set up your client to receive the messages, but a server.

This may help your understanding: check out the Gomoku example (https://github.com/aws-samples/aws-gamelift-sample), the architecture diagram alone should be helpful.

1 (and 3). So maybe I misunderstood you when you said “I think your client needs to use that SQS queue and process the notifications as they
come in.” Which leaves my question open: How is the client able to know
when a GameSession was created, so that it joins automatically? I mean the documenation
is clear about setting up SNS, but not very precisly in how (for UE4 e.g.) as there are many possibilities (mail, http, lambda…)

  1. Yeah I got that, but with Unreal (or Unity) I connect to a server via IP
    and Port of that Server. Yes, I can create and get different GameSessionsArns, but I only know of one way in Unreal to join a Server and that is by providing a IP. So I guess I have to dig deeper here and maybe need some kind of MasterServer after all, which assignes Players to the corresponding Server-instance, that has the GameSessionArn assigned.

Thanks for providing me with all the help.

Hi @BZ_PSU,

Sorry, I haven’t been the best at articulating this. What I was trying to say is:

your game client does not need to receive the notifications. Your client service (which is a service you write to talk to GameLift) would be receiving and processing those.

I think this illustrates it better: https://docs.amazonaws.cn/en_us/gamelift/latest/developerguide/gamelift-architecture.html

#2 I think you’re on the right track. Sorry, I wasn’t aware of the specific APIs in Unreal/Unity to connect to game sessions.