Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Match Up - Drop in matchmaking system

Discussion in 'Assets and Asset Store' started by thegreatzebadiah, Nov 7, 2017.

  1. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Last edited: May 16, 2018
    dylan92, Kobaltic1 and LostPanda like this.
  2. Kobaltic1

    Kobaltic1

    Joined:
    Jan 22, 2015
    Posts:
    183
    Thank you. I tested it and it is working great.
     
  3. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
  4. lucasmontec

    lucasmontec

    Joined:
    Apr 7, 2015
    Posts:
    97
    @thegreatzebadiah I bought NAT Traversal so that I can avoid using Unity's relays, is this asset the same idea? To avoid Unity's matchmaking servers? If I buy this I can just host the facilitator and match maker and I'm done?
    Also, is the matchmaker code avaliable? So that we can customize the way it responds, or even extend it?
     
  5. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Yeah, same idea, if you're not happy with Unity's matchmaking, Match Up can completely replace it (and more).

    Unfortunately you'll still be dependent on Unity's relay servers if you want to guarantee connection 100% of the time. Match Up does not act as a relay, it's just a plain matchmaking server that stores a list of matches. It won't help you avoid using Unity's relays unfortunately.

    Absolutely, it's all included with the plugin. The full client code as well as the c++ server code for both linux and windows. It's also all fully documented of course :)
     
  6. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    @ thegreatzebadiah thanks for work.May provide a relay server implementation? Unity is too expensive, I think a lot of people need a separate relay server to replace untiy bulit in relay server. Do you have such a plan? thank you very much.
     
  7. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @LostPanda I've been throwing around the idea, but I'm not sure yet how serious I am. I wouldn't rely on me putting anything out soon but maybe "eventually"
     
    LostPanda likes this.
  8. RoyArtorius

    RoyArtorius

    Joined:
    Jul 11, 2013
    Posts:
    73
    I do have a bit of a question, can the Match Up server program be configured to filter out matches like using NOT EQUALS or NOT LIKE? Obviously I can just filter the matches manually when grabbed from the server, but it would be more secure if the matches were filtered out before being downloaded, like to prevent users from hacking their way into matches of other users that have blocked them.
     
  9. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @RoyArtorius It's not possible right now but I'll get it into the next update. I really just didn't think of it or it would already be in there. Thanks for the suggestion.
     
  10. RoyArtorius

    RoyArtorius

    Joined:
    Jul 11, 2013
    Posts:
    73
    Awesome! :D
     
  11. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @RoyArtorius
    Thanks again for the suggestion! I just pushed the new version with NOT_EQUALS and NOT_LIKE to the Asset Store. It can take anywhere from a few days to over a week for it to show up.

    Email me at the support email if you want it sooner.

    That goes to anyone else as well, you'll just have to provide your invoice number.
     
    RoyArtorius likes this.
  12. RoyArtorius

    RoyArtorius

    Joined:
    Jul 11, 2013
    Posts:
    73
    You're welcome! Just sent you an email :D
     
  13. dylan92

    dylan92

    Joined:
    Jul 10, 2012
    Posts:
    32
    @thegreatzebadiah I just got match up integrated into my game and the server running on my windows EC2 instance. It seems to work well and it was really easy to swap in! There's a few things that I ran into though that could be addressed:
    • At first everything seemed to be working well, but I logged into my EC2 instance and found the console window for Match Up spamming "Error while receiving message from client: 256". I believe this is caused by calling Matchmaker.DestroyMatch as the game is shutting down. If I call that as I leave a match but don't shut down the game I don't get the log spam, but if I call that from an OnDestroy function as I quit the game (or exit play mode in editor) I get the log spam.
    • Instead of just Matchmaker.GetMatchList, could you add a new function to get the MatchData for a specific match like Matchmaker.GetMatch(long matchId, Action<bool, MatchData> onGetMatch) ? This would be useful for getting the latest changes for a match without having to pull the entire match list down first.
    Thanks!
     
    RoyArtorius likes this.
  14. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @dylan92
    I'll fix that first problem and add that feature. It's a great idea. Thanks for the feedback!
     
    dylan92 likes this.
  15. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @dylan92
    I just submitted the new version to the asset store with the fix and the new method. It should be on the store within a week but feel free to email me at the support email if you want it sooner.
     
    dylan92 likes this.
  16. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    Hey, this looks awesome!

    I have one question. Let's say I use both NAT Traversal and Match Up, and I want to use Unity's relay servers to support those rare 100% connection cases where even NAT Traversal fails. So, how would I do this using your plugins?

    I would assume that when creating an internet game, I would always need to register my game for both Match Up and Unity's matchmaking. On client side, I search for games and the server browser lists those games that are registered with Match up. I would always try to connect with Match Up first. Then, if direct connection fails, NAT Traversal takes over, and if this fails as well, I would need to connect with Unity matchmaking in order to use the relay servers. I guess I could just use the match information provided by Match Up (like IP) to look up the same match in Unity's matchmaking list, and then connect there.

    Does it work as easy as this, or do I have missed something? Thanks! :)
     
    Last edited: Apr 5, 2018
  17. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    It should be even easier than that. You should be able to store the unet match's network ID (as a ulong) in the match data:
    Code (CSharp):
    1. IEnumerator HostAMatch()
    2. {
    3.     ...
    4.  
    5.     // Wait for the unet match
    6.     while (netManager.matchInfo == null) yield return 0;
    7.  
    8.     // Add the guid to the match data
    9.     var matchData = new Dictionary<string, MatchData>() {
    10.         { "Match Name", matchName },
    11.         { "guid", netManager.natHelper.guid },
    12.         { "unetMatchID", (ulong)netManager.matchID }
    13.     };
    14.  
    15.     // Create the Match with the associated MatchData
    16.     this.CreateMatch(netManager.maxConnections + 1, matchData);
    17. }
    The clients can then pull the match ID from the match data and pass it in to StartClientAll() along with the rest of the info:
    Code (CSharp):
    1. NetworkID unetMatchID = (NetworkID)(ulong)match.matchData["unetMatchID"];
    2.  
    3. // Connect to the host
    4. netManager.StartClientAll(externalIP, internalIP, port, guid, unetMatchID);
    Everything should be handled for you after that.
     
    moco2k likes this.
  18. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    Sounds perfect, thanks!
     
  19. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I just submitted Match Up 1.05 for release.

    If anyone is hosting their own server and getting int parsing errors you'll want to update to the new version when it is out.

    I also updated the test server so if anyone using the test server has been having issues creating / joining matches that should be fixed now.
     
  20. gary1983

    gary1983

    Joined:
    Feb 24, 2018
    Posts:
    1
    I'm your fans, I bought three of your assets

    it's works fine but not prefect , because I can't throw unet relay service away.

    I wish a relay server assets come soon !

    great work!

    thank you !!!
     
    LostPanda and thegreatzebadiah like this.
  21. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    It's kind of a secret but...I'm working on it
     
    LostPanda likes this.
  22. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Match Up 1.05 Released
    • This update contains changes to the server, so if you're hosting your own make sure to update it with the new executable.
    • Fixed handling of unsigned long values on the server.
    • That's all for now.
     
  23. Gotcab

    Gotcab

    Joined:
    Apr 22, 2017
    Posts:
    6
    Hi, I'm in the process of making a HoloLens multiplayer app over the internet and there is some incompatibility with HoloLens platform in Matchup. I found a simple way to make it work. Here is the workaround if you want to include it in your next update so you can say that it is compatible with HoloLens:

    In NetworkManagerExtension

    Add this method:

    Code (CSharp):
    1. public static string GetInternalIP()
    2.         {
    3.             IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
    4.  
    5.             foreach (IPAddress ip in host.AddressList)
    6.             {
    7.                 if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
    8.                 {
    9.                    return ip.toString();
    10.                 }
    11.             }        
    12.             throw new Exception("No IPv4 network adapter found on your device!")
    13.         }
    Replace Network.player.ipAdress with this method:
    Code (CSharp):
    1.  // Client and host are behind the same router
    2.                 if (hostInternalIP == GetInternalIP())
    Replace it again in Matchmaker:

    Code (CSharp):
    1. public void CreateMatch(int maxClients, Dictionary<string, MatchData> matchData = null, string matchName = "", Action<bool, Match> onCreateMatch = null)
    2.         {
    3.             if (matchData == null) matchData = new Dictionary<string, MatchData>();
    4.             if (networkManager)
    5.             {
    6.                 if (!matchData.ContainsKey("internalIP")) matchData["internalIP"] = NetworkManagerExtension.GetInternalIP();
    That's about it. If you change this, don't forget to mention that your script will only work on HoloLens when using IL2CPP scripting backend. I'll try to make the changes to make it work on .NET scripting backend too and contact you if it works. Again, thank you for your awesome assets!
     
    Last edited: Apr 20, 2018
    thegreatzebadiah likes this.
  24. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Awesome man, you rock. I'll make sure to get it in the next release.
     
  25. Gotcab

    Gotcab

    Joined:
    Apr 22, 2017
    Posts:
    6
    Great, I updated GetInteralIP() in my previous post to flush out UnityEngine.Network because all legacy network namespaces like UnityEngine.Network are gonna get removed in 2018.2. Secondly, .NET scripting backend on UWP is gonna get deprecated so I won't bother fixing the problems related to it.
     
  26. somosky

    somosky

    Joined:
    Feb 15, 2014
    Posts:
    138
    Hi I bought your asset today and I've made quite a few changes to it and it's working great so far. One question I have is is that when the match list is called it calls it on a GUI button. I'm very unfamiliar with how GUI and networking works with Unity .I've switches out the Host and GetMatcg GUI buttons with Unity UI buttons with no issues but the match list one is proving more difficult .

    I'm attempting to just create a panel where the matches will be listed and then instantiate prefab of buttons with the matches to join in them as opposed to the GUI buttons. I'm using the Emample U Net script currently .
     
  27. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @somosky I'm not super familiar with the UI stuff but I whipped something up that I think should get you some buttons:
    Code (CSharp):
    1.  
    2.     /**
    3.      * This is called when the match list is received after calling GetMatchList()
    4.      */
    5.     void OnMatchListGot(bool success, Match[] matches)
    6.     {
    7.         if (!success) return;
    8.  
    9.         Debug.Log("Received match list.");
    10.         this.matches = matches;
    11.  
    12.         for (int i = 0; i < matches.Length; i++)
    13.         {
    14.             Match match = matches[i];
    15.             string matchDesc = "";
    16.             matchDesc += match.id + "|";
    17.             matchDesc += match.matchData["Match name"] + "|";
    18.             matchDesc += match.matchData["eloScore"] + "|";
    19.             matchDesc += match.matchData["Region"] + "|";
    20.             matchDesc += match.matchData["Map name"] + "|";
    21.             matchDesc += match.matchData["Game type"];
    22.  
    23.             Button button = GameObject.Instantiate(buttonPrefab).GetComponent<Button>();
    24.             button.transform.SetParent(canvas.transform, true);
    25.             button.GetComponent<RectTransform>().anchoredPosition = Vector3.up * i;
    26.  
    27.             button.GetComponentInChildren<Text>().text = matchDesc;
    28.  
    29.             button.onClick.AddListener(() => { matchUp.JoinMatch(match, OnJoinMatch); });
    30.         }
    31.     }
    Replace the default OnMatchListGot() method with that one. You'll need the reference to the canvas and the button prefab of course. I didn't do much for positioning or styling so that's up to you, but that should at least get you one clickable ui button.
     
  28. somosky

    somosky

    Joined:
    Feb 15, 2014
    Posts:
    138

    Hi I tried this and it did create the button properly. However when I try to join the match I get the error "Must set the Network Address Field in the manager. UnityEngine.Networking.NetworkMangerExtension:StartClient(NetworkManager, Match)

    So it seems the match ID is not being sent through the click event on the button.
     
  29. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @somosky
    The Network Address Field gets set in the NetworkManagerExtension when you call StartClient(). The only way I can see it being wrong is if it wasn't included in the match data. It is supposed to be added automatically for you in Matchmaker.CreateMatch(). I can see two ways things could go wrong here. Either there was no NetworkManager in the scene when Matchmaker.Start() was called, or you're calling CreateMatch() before the external IP has been fetched. You should try waiting until until NetworkManagerExtension.externalIP != "" before creating the match.

    You could also try outputting match.matchData["internalIP"] and match.match.Data["externalIP"] in OnJoinMatch() to see what you're getting there.
     
  30. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    I have bought three of your assets ,all your assets is great but i am really need relay server assets come soon ! thanks man.
     
  31. ceitel

    ceitel

    Joined:
    Jan 3, 2017
    Posts:
    35
    @thegreatzebadiah ,

    Problem: I am running a simple Ubuntu machine as a server with both your Match Up server and your Nat Traversal server on the same local network with the machines I want to create matches with (think computer lab) (running ExampleMatchUp from the NATTraversal package). Currently I want to simply create the matches over the local network but in the future I would like to have the server outward facing and actually use the NAT traversal. At the moment, they easily find the Matchmaker via it's local IP and the match list populates as expected, but upon attempting to "connect directly":
    netManager.StartClientAll(externalIP, internalIP, port, guid);
    It attempts to connect to the externalIP instead of the host computer's internalIP address and (I'm guessing because the NAT server is not outward facing yet) does NOT successfully set up a connection via NAT Traversal. I am able to circumvent this issue by replacing the code above with:
    netManager.StartClientAll(internalP, internalIP, port, guid);
    but it would be nice if it would first try to connect over the local network before attempting the external ip and then NAT Traversal.
    [interestingly the original code connects just fine if I am running 2 instances of the game on the same machine and it correctly "connects directly" over IP 127.0.0.1]

    I am in no way experienced enough in networking to know what I'm talking about so I may be missing something simple (I'm also programming behind some serious university networking/firewalls)

    Also: I saw a while back you had written a MatchUp server for Windows but the link is now broken, is that still available?

    Thanks in advance!
     
  32. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @ceitel I can see where the NAT Traversal plugin is failing for you. I am no networking topology expert myself and it looks like I did not account for university / corporate intranet setups very well. I'm looking into expanding the plugin a bit to do what you suggested (try local ip first then external) but it's not trivial so it might take a bit to get done. I'll let you know when I've got a new build that you can test.

    The windows build of the Match Up server should be included with the plugin but I'll make sure to update the link as well.
     
  33. AzraelKans

    AzraelKans

    Joined:
    Oct 29, 2009
    Posts:
    135
    Sorry for the silly question, is this compatible for mobile too?
     
  34. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
  35. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @ceitel It seems like you've somehow renamed your Facilitator to MatchUpServer and it's failing to start because the Facilitator port is already taken. That output definitely looks like it's from the Facilitator and not the MatchUpServer at least.
     
  36. GCatz

    GCatz

    Joined:
    Jul 31, 2012
    Posts:
    282
    does the server works with the http protocol ?
    I'm thinking about implementing websocket in Match Up
     
  37. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Nope. You can dig in to the match up client code and see what it looks like. I use a NetworkStream backed by a TCPClient and send ASCII encoded text. The code is provided for both the client and server though so it should be possible to get it working any way you want. I'm not familiar with websockets myself so I wouldn't really know where to start, but if you figure anything out let me know and I can work it into the plugin.
     
  38. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
  39. dylan92

    dylan92

    Joined:
    Jul 10, 2012
    Posts:
    32
    @thegreatzebadiah I just updated my project to Match Up 2.0 and now I'm getting these errors in the editor:


    Match Up: Error parsing GetMatchList response from matchmaking server.System.NullReferenceException: Object reference not set to an instance of an object
    at MatchUp.Matchmaker.OnGetMatchListInternal (Boolean success, System.String response, System.Action`2 onMatchList) [0x00098] in C:\UnityProjects\floodedMarket\Assets\Plugins\Match Up\Matchmaker.cs:523
    UnityEngine.Debug:LogError(Object, Object)
    MatchUp.Matchmaker:OnGetMatchListInternal(Boolean, String, Action`2) (at Assets/Plugins/Match Up/Matchmaker.cs:552)
    MatchUp.<GetMatchList>c__AnonStoreyB:<>m__0(Boolean, Transaction) (at Assets/Plugins/Match Up/Matchmaker.cs:408)
    MatchUp.Transaction:Timeout() (at Assets/Plugins/Match Up/Internal/Transaction.cs:42)
    MatchUp.<TimeoutTransaction>c__Iterator3:MoveNext() (at Assets/Plugins/Match Up/Matchmaker.cs:609)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)



    Transaction: Timed out waiting for response from matchmaking server.
    UnityEngine.Debug:LogError(Object)
    MatchUp.Transaction:Timeout() (at Assets/Plugins/Match Up/Internal/Transaction.cs:40)
    MatchUp.<TimeoutTransaction>c__Iterator3:MoveNext() (at Assets/Plugins/Match Up/Matchmaker.cs:609)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)


    On the server (Amazon EC2 Windows instance), I'm seeing messages like this:

    Parsing page number. Failed to parse int from string: PAtnLfIxoU9s2fdH|0


    Any ideas?
     
  40. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @dylan92 Any time you update the plugin you should also update your server. The windows server is in Assets/Plugins/Match Up/Server/MatchUpServer_Windows.zip. Replace your currently running Match Up server with those new files and you should be good to go.
     
  41. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I am being slow but It's still coming.
     
    LostPanda likes this.
  42. unity_lMIeOVJm710RxQ

    unity_lMIeOVJm710RxQ

    Joined:
    Jul 1, 2018
    Posts:
    3
    Whenever I run the Match Up demo scene the host starts just fine, but the client isn't able to connect and it eventually times out. This is what appears in the client log:

    Log: cannot connect after {10} attempt address {::ffff:73.189.179.172:7777}
    ClientDisconnected due to error: Timeout

    73.189.179.172 is my public IP address. The same thing happens when I use Match Up in my game. Connecting to my server in my game works fine when I use Unity's NetworkHUD instead of Match Up.

    Any thoughts on how to fix this?

    EDIT: I have now tested this on three different wifi networks and I'm getting the same timeout on all networks. I'm running host and client on the same machine. The client is able to get the list of games, but not join one. I was able to host and connect to matches using Unity's NetworkHUD. Please advise.
     
    Last edited: Jul 26, 2018
  43. AurelWu

    AurelWu

    Joined:
    Oct 11, 2013
    Posts:
    26
    have played around with the unity inbuild matchmaker the past days and yours has some features I really miss from theirs. However being rather inexperienced with networking stuff still, I am happy that I got it working at all now and as my game is turnbased the Unity Relay Server pricing won't be an issue. Would combining the two work without too much trouble and is there a simple example for that use case around? UNET documentation is so all over the place that I'm not ashamed to ask for pointers ;)
     
  44. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @AurelWu Funny you should ask. There is an update awaiting approval right now that adds relays to the example scene / script. It will probably be live in the next couple of days.
     
    AurelWu likes this.
  45. AurelWu

    AurelWu

    Joined:
    Oct 11, 2013
    Posts:
    26
    okay, just bought it :)
     
    thegreatzebadiah likes this.
  46. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Sorry I totally missed this message until right now. Maybe I've already helped you via email but in case I haven't, it sounds like you're running into NAT issues. The reason that it works via the Unity HUD is that the default networking uses the relays. The example script included with Match Up does not use the relays right now, it only connects directly, which is often blocked by routers in the real word. The latest update includes a check box that adds relay support to the example but it has not been approved yet. It should go live in the next couple of days.
     
  47. AurelWu

    AurelWu

    Joined:
    Oct 11, 2013
    Posts:
    26
    Just started testing your asset. 2 things I instantly noticed:
    a) Building for windows fails because AddScriptingDefines.cs uses UnityEngine.Editor namespace. Should be put into Plugins/Match Up/Internal/Editor Folder.
    b) OnUNETMatchCreated(bool success, string extendedInfo, MatchInfo response) should provide a debug message when success = false + the extendedInfo. Took me way too long to figure out why I always got "unetMatchID missing from match data. Can not connect via relay. Falling back to direct connect" from the OnJoinMethod before I figured out where the error lies.

    With that out of the way it looks promising so far though.
     
  48. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @AurelWu

    a) Yep, that's exactly what I get for not building and just testing in editor for the last release. I'll get it fixed up in the next release ASAP, but at least in the meantime it's an easy enough fix.

    b) OnUNETMatchCreated is a callback used by UNET, which unfortunately does not provide any more info. The best I can do is pass on what Unity gives me. I do agree that it is lame though.
     
  49. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Just a heads up, I just submitted a new version of Match Up, so for anyone running into the editor script issue preventing them from building, a fix will be out soon!
     
  50. RoyArtorius

    RoyArtorius

    Joined:
    Jul 11, 2013
    Posts:
    73
    Hi, I'm having an issue getting the Windows server version of MatchUp working. I noticed that the ip addresses listed are just loopbacks (127.0.0.1) Is that normal?