Search Unity

Cleaning up match rooms when host leaves

Discussion in 'Multiplayer' started by SpeakUpGames, Oct 19, 2015.

  1. SpeakUpGames

    SpeakUpGames

    Joined:
    Nov 25, 2014
    Posts:
    56
    There's an issue with the matchmaker not cleaning up rooms after the host leaves. Meaning that you can create a room, leave and rejoin and it causes issues. If anyone else was having this issue, I might have found a way around it with the following overrides in my extension of NetworkLobbyManager:

    Code (CSharp):
    1.  
    2.     public override void OnMatchCreate(CreateMatchResponse matchInfo)
    3.     {
    4.         base.OnMatchCreate(matchInfo);
    5.         if(matchInfo.success) {
    6.             hosted_room_match = matchInfo;
    7.         }
    8.     }
    9.    
    10.     public override void OnStopHost() {
    11.         base.OnStopHost();
    12.         matchMaker.DestroyMatch(matchInfo.networkId, null);
    13.     }
    Where hosted_room_match is a CreateMatchResponse member variable of the class. I wanted to simply store the NetworkID but Unity gives me issues with storing that enum.
    Being able to re-join bogus matches is a serious issue we needed to solve before launching so I couldn't wait for a unity fix.
     
  2. JeremyUnity

    JeremyUnity

    Joined:
    Mar 4, 2014
    Posts:
    147
    That looks good. There's a 30 second timeout after a client leaves before the default cleanup routine is run, and matches themselves are cleaned up when there is no one left. You can disconnect a client by calling DropConnection as each client leaves, it's recommended over DestroyMatch.
    Currently Unity expects all enums to be 32bit at the moment, and some of the UNet IDs are 64bit. if you're running into the serialization issue with 64bit enums you should be able to store the NetworkID as a ulong until that's fixed.
     
    SpeakUpGames likes this.
  3. SpeakUpGames

    SpeakUpGames

    Joined:
    Nov 25, 2014
    Posts:
    56
    Thanks for the insight into the matchmaker. Is there a reason DropConnection is better over DestroyMatch? I haven't found a way to filter out matches that shouldn't be joined, or even prevent a player from joining one, so waiting for the default cleaning isn't an option.
     
  4. JeremyUnity

    JeremyUnity

    Joined:
    Mar 4, 2014
    Posts:
    147
    DropConnection is preferable because no one will be forced out of a match, it's mostly a notification mechanism to our service that a specific seat has left and you can clean up immediately. DestroyMatch is intended as a hard termination, which will force all seats to close abruptly.
    As for match filtering, we're adding more functionality to the services. Our backend already includes the ability to toggle if a currently running match is listed in search results, for instance, so once that interface code is in the client you'll be able to leave a match listed until you choose to delist it because you don't want anyone else to see the match and join it.
     
  5. SpeakUpGames

    SpeakUpGames

    Joined:
    Nov 25, 2014
    Posts:
    56
    Perhaps I'm not being clear with the issue I'm having.
    When I create a match and immediately leave, the match still exists in the match list. Then when I try to connect again, it gives me the following error:
    And the game needs to be re-started. I can't have this happen in production, so I need a way to either destroy those matches immediately, or prevent users from joining bogus matches that are still showing up while waiting to be cleaned.
     
  6. JeremyUnity

    JeremyUnity

    Joined:
    Mar 4, 2014
    Posts:
    147
    Hi SpeakUpGames,
    That's a known issue right now, only with rejoins. There's a fix in the pipeline but it's not yet released.
    DropConnection will still clean up the match when everyone leaves. To avoid rejoining the old match however you can specify a new match for JoinMatch or call CreateMatch to create one.
     
    holliebuckets likes this.
  7. OutSourceStudio

    OutSourceStudio

    Joined:
    Nov 7, 2015
    Posts:
    2
    Subscribing on this one, having the same problem..
     
  8. Gorgor

    Gorgor

    Joined:
    Apr 28, 2012
    Posts:
    51
    This is a VERY old and know problem. Basically it renders using matchmaking totally useless in production. It would be great if unity give this one CRITICAL priority otherwise UNET is not ready for anything serious.
     
  9. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Since there's already a workaround, it will never have critical priority. At most, it will have normal or +1 tier higher than normal priority.
     
  10. jinnindo

    jinnindo

    Joined:
    Dec 8, 2015
    Posts:
    17
    What is the workaround?
     
  11. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    At the time, I was referring to what @JeremyUnity said. Now? I don't know if there were underlying changes that made UNET Matchmaking work or not. I don't know if there are any workarounds right now.

    If the issue in this thread (the very old and known issue one) is still not fixed, then that confirms my post that it will not have critical priority. But I hoped I am wrong about this.
     
  12. jinnindo

    jinnindo

    Joined:
    Dec 8, 2015
    Posts:
    17
    So far, it seems this particular problem (unable to rejoin after leaving matches) is solved in the 5.4 beta.
    But a few untenable issues remain, and more have sprung up.
    I accept this is part of a process, but it's frustrating when you don't get answers.
    Still we go on.
     
    Westland likes this.
  13. kortenoever

    kortenoever

    Joined:
    Jun 12, 2013
    Posts:
    11
    Any update on this?

    When the someone creates a game and then leaves, the game will remain in the matchmaking listings. Players then can join the match that has no host, so they are stuck. OnClientConnect is not being called (because there is no host to communicate with?). Tried destroying the match when a player joins, but only the host can do that.

    The match will get automatically destroyed in 30 seconds, but in this time a lot of players can get stuck.

    Anyone got a solution for this?
     
  14. lejean

    lejean

    Joined:
    Jul 4, 2013
    Posts:
    392
    Unlist the match should do the trick, check this. When you have enough ppl in ur match, change the islisted to false.
     
    jinnindo likes this.
  15. Deleted User

    Deleted User

    Guest

    But how do I shorten this time, Jeremy? I do not want 30 seconds! :(
     
  16. kaarelr

    kaarelr

    Joined:
    Feb 26, 2016
    Posts:
    8
    Sorry for bumping this.

    The way I implemented it right now is how "lejean" suggested, but now I'm wondering how I should handle the situation when the host quits while nobody has joined the match yet. It will remain in the matchmaking list and people can join it.