Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Matchmaking - Match Lifecycle and Joining Dead Games

Discussion in 'Connected Games' started by kromenak, Mar 31, 2016.

  1. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    250
    I'm trying to use the matchmaking service to create a match between two clients. My algorithm is currently this:
    1. List the available matches. If one is available, join it.
    2. If no matches are available to join, create a match instead.
    Generally, this logic works as I'd hope.

    While testing, I noticed that frequently my client would create a match, and then I'd stop the editor to tweak something, and then when I hit play again, my client would join the match that it had created on the previous run! Of course, that match is garbage at this point, since the host has left.

    I noticed the DestroyMatch call in the NetworkMatch component, so I tried having the host call that when quitting the app or backing out of the matchmaking process. However, I STILL have the same problem where my client will join matches that it had just abandoned, despite calling DestroyMatch and getting a success callback.

    So, why is it possible to do this? It seems like a big problem in production if any created match where the host has backed out essentially leaves a "zombie match" in the system for some unfortunate client to join. Am I not managing the lifecycle of a matchmaker match properly? Is there any way, before joining a game, for me to detect that this will be a problem and NOT join it appropriately?
     
  2. Nicolas-Liatti

    Nicolas-Liatti

    Joined:
    Jun 19, 2013
    Posts:
    89
    I have the same problem. Any help would be highly appreciated... :(
     
  3. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    250
    I just had a playtesting session with a bunch of people in the company, and predictably, people frequently joined to matches that were DOA. Seems like a pretty glaring flaw?

    I think it's really important to be able to understand the lifecycle of matchmaking objects in the system, and what the developer responsibilities are for handling them. It's clear that matches are created using CreateMatch. But to destroy a matchmaking object, do you need to explicitly call DestroyMatch? If the match is filled (say, the max number is 2), is the matchmaking object no longer returned when you call ListMatch? What if the match is filled, but then a player leaves: is it shown in ListMatch calls? Should I be calling DestroyMatch as soon as the match is "locked in" and started, since the matchmaking phase is over?

    I feel that there are a number of scenarios where it's not clearly specified how to proceed.
     
  4. JeremyUnity

    JeremyUnity

    Unity Technologies

    Joined:
    Mar 4, 2014
    Posts:
    147
    Hi @kromenak
    Matches last while at least 1 client (that includes the host) is connected.
    Individual connections last as long as there's traffic going to relay server, and there's a 30 second window from the time it last receives a message from a client and when that client is cleaned up and removed from the match. Additionally, a client may remove themselves immediately and skip the timeout by calling DropConnection. Don't bother with destroy match unless you have some weird emergency cleanup needed. I'll look into why it would return success and not be destroyed though.

    You should know DropConnection will only work for either the match host or the actual client being dropped. Everyone else will be access denied. DestroyMatch only works for the host likewise, no one else can call it and have it destroy the match.

    As for match lifetime, the match is cleaned up the instant the last connection drops from it.

    As for listmatch, it does return full matches. I'm planning on adding a feature to specify if you want full matches or not to show up, but for now you could explicitly call the SetMatchAttribute request and delist the match by using the isListed functionality. That will prevent the match from showing up in future list results.

    You should also know in 5.4 DropConnection will be called automatically and SetMatchAttributes are defined. For 5.3 and earlier it's a bit manual to use them but the service supports it.
     
  5. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    250
    Great, I'll give that a shot. Thanks for the info!
     
  6. carmine

    carmine

    Joined:
    Jan 4, 2012
    Posts:
    391
    I'm also having a problem with dead/stale matches. I'm currently in development. No one else is accessing this.

    I've tried quitting Unity and even rebooting my machine, but it still thinks the Match is active.

    Please advise (I'm using the latest version of Unity) 5.3.4

    -Carmine
     
    GrymmyD likes this.
  7. GrymmyD

    GrymmyD

    Joined:
    Dec 2, 2015
    Posts:
    42
    @JeremyUnity I am experiencing this as well. I believe there's been some sort of regression regarding dead match cleanup.
     
unityunity