Best way to handle Matchmaking cancel/crash/quit in Unity

Hello,
we are trying to handle when a user closes the game in the middle of a match in Unity, and we were wondering what’s the best way to operate when getting the error 520300 unable to create match ticket: a matching resource already exist.
The thing is that if a user quits a match and tries to search for a new match right away they will get the stated error. My guess is that we should call DeleteMatchmakingTicket whenever we detect that the user has a ticket going on, but… are there any downsides to doing that?
Should we check something first?

Thanks a lot!

Hi @xalbertus1,

Users can only have one active match ticket at a time. Once a user finds a match, the ticket should be marked as found, allowing you to create a new match ticket. If the user intends to cancel the matchmaking process, you need to call DeleteMatchmakingTicket.

If I understand correctly, the user already found a match, played a bit, quit the match, then started matchmaking again but failed. I recommend using tools like Fiddler to troubleshoot and track the matchmaking state more effectively. It can help you monitor and analyze your API calls to ensure that the matchmaking flow is correct.

@Damar just to clarify, the question is what do we do when we receive the 520300 error code when creating a matchmaking ticket? For example the client crashes after creating the matchmaking ticket, then after restarting the client attempts to create a new ticket while the previous ticket is still in progress. Should we just delete it? I had considered maybe doing nothing and treating that in flight ticket as our current ticket, but the matchmaking params may not match between that request and our new request (ex: game modes are different).

@Damar after talking with @xalbertus1 more I realize that we have 2 issues that need resolving here. We still need to know how to handle the error given that the client can crash and/or quit in an unclean way while the ticket is still searching, the other is as you and @xalbertus1 already discussed. Specifically, we’re creating a matchmaking ticket that is being resolved with a game session. After playing the game session, we’re no longer able to matchmake again as it would appear that the previous ticket was never marked as found. As you said, the match was created and therefore the ticket should have been marked found so I don’t see how going the route of using Fiddler to troubleshoot client-side SDK network traffic is a reasonable approach at this stage of troubleshooting. Can we not start by giving you matchmaking ticket IDs?

Here’s an example of an error, with a ticketID:

[Warning][AccelByteSDK][2024-08-14T16:52:39Z]HTTP Response: 
---
HTTP/1.1 409
Date : 2024-08-14T18:52:39Z
Content-Length : 283

{
 "errorCode": 520300,
 "errorMessage": "unable to create match ticket: a matching resource already exist: ticketID, userID: ad1c0aac75be4d66b190e21a26b0dec9, , ticketID: adfafa3167344707b49e95354486bb4d",
 "messageVariables": {
  "ticketID": "adfafa3167344707b49e95354486bb4d"
 }

Hi @njupshot @xalbertus1,

After a discussion with the internal team, we have the following recommendations for handling this case. You can put it before start matchmaking. The flow should be:

  1. Get current user match ticket: Call GetUserMatchmakingTickets to check if a match ticket already exists.
  2. If a ticket exists:
  • Delete the existing ticket using DeleteMatchmakingTicket.
  • Wait for the response confirming the deletion.
  • Create a new match ticket.
  1. If no ticket exists:
  • Directly create a new match ticket.

Hope this answers your question.

Hi Damar,

I just did what you suggest and it does not work. The steps I am taking:

-Check if the user has an ongoing ticket (GetUserMatchmakingTickets)
->If there are no tickets, proceed with new ticket creation (CreateMatchmakingTicket)
->If there are tickets active, delete, wait for the confirmation and then proceed with new ticket creation (DeleteMatchmakingTicket and then CreateMatchmakingTicket)

And what’s happening is that when there is an active ticket, after calling DeleteMatchmakingTicket the response is successful but when we try to create a new ticket it fails again due to the same error; it’s like the ticket is not being deleted.

Hi @xalbertus1,

If possible, could you share your user ID and the timestamp (in UTC) when the issue occurred? This will help me track the flow and understand what happened and why it happened.

Replied some info on DM

Thank you @xalbertus1 for the detailed information. After checking with the internal team, we discovered a bug affecting solo matchmaking. We are working on a fix, and I will notify you once it has been deployed.

In the meantime, you can implement a retry mechanism as a workaround. The flow should remain the same, but after creating a match ticket, if it fails and gets an error 520300, add a retry after a specified number of seconds.

The retry mechanism doesn’t work and we end up waiting on the order of minutes before we’re allowed to matchmake again. We’ve tried deleting the ticket and that doesn’t work either. Talking to @xalbertus1 through DM it sounds like this is a known issue on AB’s side. If that is indeed the case the we need an update as this is greatly impacting our ability to test and iterate.

As per our discussion in the private message, we identified that the issue was due to the match ruleset, where all numbers were set to 1:

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

This is a known issue, and we will deploy a fix in the next update. As a temporary solution, we recommend reducing the ticket expiration to 3-5 seconds. This way, after a match ticket is created, it will automatically be deleted after 3-5 seconds, as you should instantly get a match.
image

Hi @njupshot @xalbertus1,

We have deployed a hotfix to address the issue where the ruleset team alliance numbers were set to 1. Please let me know if you are still encountering any problems.