Search Unity

[Released] Master Server Kit: create your own UNET-based dedicated server

Discussion in 'Assets and Asset Store' started by gamevanilla, Oct 14, 2016.

Thread Status:
Not open for further replies.
  1. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    First of all, thank you for your interest!

    The kit is game-agnostic, meaning it is intended to be used with a wide variety of games. Please note that programming the RTS logic is your responsibility and the kit will not help you with that, as it is focused on the more general player registration/authentication, matchmaking and player data storage functionality. In order to program the logic of your game, you will need to use regular UNET (your network messages, commands and SyncVars will all work as usual, with the only difference being that your game will be running on a dedicated server instead of being player-hosted via Unity Services).

    The authentication and database storage are optional features and as such you are not forced to use them if you do not want or need to.

    Yes. You will need a dedicated server with a public IP address; I describe the deployment process to a Digital Ocean VPS here.

    That is an impossible question to answer, generally speaking. The exact numbers will depend on both your game and the capabilities of your server, so the only way to know for sure is to test in a real, concrete scenario.

    Not currently, but that is an excellent idea. Definitely noted, thank you!

    I hope this helps!
     
  2. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Hello! Version 1.09 of the kit is now available on the Asset Store. These are the release notes:
    • Added a new version of the ClientAPI's CreateGameRoom method that accepts a list of properties.
    • Added hideWhenFull field to the game server component that allows game servers to be removed from the matchmaking results once they are full.
     
  3. CPTEliteWarfare

    CPTEliteWarfare

    Joined:
    Apr 9, 2014
    Posts:
    68
    Thank you, You just made a sell :D , but yes i do have the core functions down for my RTS all using UNET code i just needed a other way for matching to happen i dont like the limit of the CCU that Unity gives and i dont want the player-hosted thing that unity does. I got Dedicated Server Boxes that i pay $100+ for :p
     
  4. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Thank you for your purchase! That sounds great and is exactly the most common scenario for using the kit. :)
     
  5. CPTEliteWarfare

    CPTEliteWarfare

    Joined:
    Apr 9, 2014
    Posts:
    68
    I got a Question would i have to add the Kit into the game project or make it a other project for the game?
     
  6. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    You can add the kit into your game project.
     
    CPTEliteWarfare likes this.
  7. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    92
    Hello,Spelltwine-Games!
    Your kit is based on Unet,but Unet CCU need Plus,Pro like that,so how to understand the no limited CCU?Thank U!
     
  8. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    You do not pay for UNET; you only pay for Unity Services which provide relay/matchmaker servers to connect players. Master Server Kit implements its own matchmaking system that allows you to host your game on a dedicated server of your own. Since it does not use Unity Services, you do not need to pay for it and you do not have any artificial CCU limits (of course, you will still be limited by your game and the capabilities of your server). You can still use your regular UNET features like network messages, commands and SyncVars as usual; they are part of the engine and as such they are completely free.

    I hope this clarifies it!
     
  9. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    92
    but how to understand "based on UNET"?your kit can run just with your own logic without UNET?
     
  10. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    You need to differentiate between UNET and Unity Services:
    • UNET is the official networking library in Unity. It is completely free to use, as is any other part of the engine.
    • Unity Services is a collection of services that Unity provides on top of UNET; mainly player-hosted games and matchmaking that avoid the need for you to host a dedicated server. These services are paid and optional to use.
    You are not required to use Unity Services if you are writing your game with UNET, but if you decide not to do that then you will need to implement your own matchmaking system in order to connect your players. This is where Master Server Kit enters the picture: it provides the custom matchmaking functionality you need to run your game on a dedicated server, plus additional useful functionality like player authentication and player data storage in a database. This functionality is implemented with UNET.

    A common use case is that you are writing your game with UNET and you want to switch from Unity Services to your own dedicated server (maybe because you need server-authoritative logic instead of player-hosted games in order to prevent cheating, or maybe because you want a higher degree of control on the back-end side). Master Server Kit allows you to keep your multiplayer gameplay code written with UNET untouched, while providing you the foundational code you need to move to a dedicated server setup.

    You are required to know UNET in order to use the kit, basically because you are responsible for writing the multiplayer logic of your game. A good starting point are the official tutorials.
     
  11. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Hello! I have just submitted version 1.10 of the kit to the Asset Store. This version adds a database provider implementation for MySQL, which is something several users had requested. As always, you can grab the update from the official private repository or, alternatively, wait a few days until it is approved. :)
     
  12. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    92
    Fantastic explaintion!Great Kit!And what is the difference between your kit and Master Server FrameWork?(Just for the main part is enough)
     
    Last edited: Apr 9, 2017
  13. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Thank you! I have not personally used that asset, so it is hard for me to explain the differences.
     
  14. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Hello! Version 1.10 of the kit is now available on the Asset Store. These are the release notes:
    • Added MySQL database provider implementation.
     
  15. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Hello! I have just submitted version 1.11 of the kit to the Asset Store. This version adds experimental support for WebGL; you can find more details about it here. As always, you can grab the update from the official private repository or, alternatively, wait a few days until it is officially approved. :)
     
  16. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Hello! Version 1.11 of the kit is now available on the Asset Store. These are the release notes:
    • Added experimental WebGL support.
     
  17. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
  18. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    92
    Movement transferred by master-server ,I think it cost too much for the master-server.Is there a example show the data trasfer between clients(UNET own propety,not through the server),so the master-server will be free.
    Thank U!
     
  19. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    I am sorry, but I do not really understand your question. What do you mean by data transfer between clients?
     
  20. yumianhuli1

    yumianhuli1

    Joined:
    Mar 14, 2015
    Posts:
    92
    I am sorry!I mean for example CS(client to server) ---the transform position data through server to client,then the server becomes very busy.
    P2P(peer to peer,client to client) I want to use data transfer by this way,then the server becomes not busy.So your perfect kit can support this way?(make match is enough!)
    Thank U!
     
  21. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    The kit is completely focused on authoritative server setups, so there is no P2P functionality included. Syncing transform data between the server and the clients is a very game-specific concern with no universally valid solution and therefore outside the scope of the kit. I link to some good introductory literature on these topics in the official documentation.
     
  22. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    126
    Hi, is there any example project that uses NetworkManager? I manage to connect to master server, but when creating room and trying to join it, the client scene never changes to game scene (master server launches new game server launches ok though using the right scene in background)

    Or maybe I need to forgot the networkmanager and try other way. It would be nice if there were some simple example of client and server that does something (maybe some simple pong game or even cubes that I could move around..)
     
  23. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Thank you for your feedback! Definitely noted. :)

    There is a step-by-step guide on how to integrate the kit with a project that uses the Network Manager component here in the official documentation; you can apply it to the accompanying demo. Please let me know if you need any further clarification and I will be happy to help.
     
  24. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    126
    Hi, thanks for quick answer and sorry it was all my fault as usual ;) I had a little problem with those callbacks (calling things in wrong order). Now everything seems to work.

    Btw. Is there way to set master server to launch those game servers with -bacthmode -nographics arguments in windows machines? I use windows server for testing and it would be nice if there was an option to launch those servers without any window.
     
  25. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    No worries at all! Happy to know you solved it.

    Not currently, but it is an excellent idea; I will implement it in the next update. Thank you again!
     
    MasoInar likes this.
  26. Alzan

    Alzan

    Joined:
    Sep 2, 2012
    Posts:
    81
    Hey! I'm having an issue with the kit. It seems like NetworkServer.SpawnObjects(); is not being called because networked scene objects are not getting enabled. It's probably an easy fix but I can't seem to get it working. Does anyone know of a solution?
    Thanks!
     
  27. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    The kit should not interfere with the standard behavior of UNET. Have you followed all the steps described in the official guide on how to integrate the kit with a game that uses the Network Manager? One that is particularly easy to miss and would cause such problems if forgotten is adding the game scene to the Builder script (this is needed because the Network Manager requires you to use two scenes; the offline and online scenes).

    If this still does not help, please send me a project showcasing the problem to the support email and I will be happy to investigate further.
     
  28. Alzan

    Alzan

    Joined:
    Sep 2, 2012
    Posts:
    81
    That seemed to do it, thanks!
    I have a custom version of the Builder script to include some extra .exe files I need for the game and I forgot to add the GameClient_Game scene to the game server function. I also had to add PlayerSettings.virtualRealitySupported = false; to everything except the actual game client because there can only be one VR enabled executable running at a time and our project has VR enabled by default.

    For others who might need it (notice that the scene directory might be different for your project):
    Code (CSharp):
    1. [MenuItem("Window/Quick Build/Build game server", false, 100)]
    2.     public static void BuildGameServer()
    3.     {
    4.         PlayerSettings.virtualRealitySupported = false;
    5.         var levels = new string[] {
    6.             "Assets/Scenes/GameServer/GameServer.unity",
    7.             "Assets/Scenes/GameClient/GameClient_Game.unity"
    8.         };
    9.         BuildPipeline.BuildPlayer(levels, "Builds/GameServer.exe", buildTarget, buildOptions);
    10.     }
    11.  
     
    Last edited: May 9, 2017
    gamevanilla likes this.
  29. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Happy to hear that! :)

    And thank you for the VR tip! I will definitely add this in the next update.
     
  30. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Hello! I have just submitted version 1.12 of the kit to the Asset Store. These are the release notes:
    • Added 'spawnGameServersInBatchMode' option to zone servers that allows spawning the game servers with the -batchmode -nographics command line arguments.
    • Disabled virtual reality support for the server binaries in the demo's builder script (as there can only be one VR-enabled executable running at a time).
    You can grab the update from the official private repository or, alternatively, wait a few days until it is officially approved on the store.
     
  31. FuTou

    FuTou

    Joined:
    May 2, 2015
    Posts:
    52
    Happy to see MSK has grown to 1.12!

    Here I have a question: If I want to auto-scale across machines on AWS, what do I do? Is there a plan to integrate that?
     
  32. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Thank you! :)

    There are currently no plans to integrate provider-specific functionality into the kit but, generally speaking, scaling across different server machines is something you can easily do with the abstractions provided (particularly zone servers).
     
  33. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Hello! Version 1.12 of the kit is now available on the Asset Store. These are the release notes:
    • Added 'spawnGameServersInBatchMode' option to zone servers that allows spawning the game servers with the -batchmode -nographics command line arguments.
    • Disabled virtual reality support for the server binaries in the demo's builder script (as there can only be one VR-enabled executable running at a time).
     
  34. dearamy

    dearamy

    Joined:
    Mar 17, 2015
    Posts:
    68
  35. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    I am not familiar with pomelo, but you can definitely have different sets of game servers running on different machines for scalability purposes.
     
  36. dell

    dell

    Joined:
    Aug 12, 2008
    Posts:
    24
    Does this product work with a UWP app as the client?
     
  37. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    126
    I haven't tested, but as it uses unity's unet networking I don't see why not.
     
    gamevanilla likes this.
  38. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    I am not familiar with UWP myself (and have not tested the kit on this platform) but, as Masolnar points out, it should work just fine considering UNET is compatible with all major platforms.
     
  39. codyraymiller

    codyraymiller

    Joined:
    Jun 1, 2017
    Posts:
    10
    Hi, Spelltwine!

    I was so excited to find your Master Server Kit. It is exactly what I have been looking for. I am having an issue getting the Demo up and running though.

    I have a server with Digital Ocean that I'm wanting to connect the demo game to. I have changed the IP address in the various demo scenes to my server's IP address, built the Linux binaries, uploaded to the server and started the master_server and zone_server on the server side. I did all of this by following the instructions included with your asset.

    Next, I built the Game Client and ran it on my Windows PC. I then built it for my android phone and ran it there. With these two GameClients running, I get the following error from the second client (whichever tries to connect second, PC or Android): ERROR Could not connect to master server.

    I am sure that I'm doing something wrong which is very simple, but I'm new to Unity and game creation in general. Can you help me?

    I really appreciate it! I just don't know where to even begin troubleshooting...
     
  40. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    First of all, thank you for your purchase Cody! :)

    That is an interesting issue. I have a pretty similar setup for the accompanying demo (a Digital Ocean VPS running Ubuntu 16.04) and can definitely connect with several clients at the same time; you can check this out yourself with the demo builds downloadable from the official documentation. Let's get to the bottom of this!

    Which version of Unity are you using?
    Is this happening only with the servers hosted on Digital Ocean or also when testing locally on your computer?
    Does this happen if you try to connect only with Windows game clients?
    Are the servers still up and running after you receive the error on the second client?

    It would also be good to know if there are any differences in your Digital Ocean setup when compared to mine; please feel free to reach me to the support email if there are any details you would prefer not to disclose publicly.
     
  41. codyraymiller

    codyraymiller

    Joined:
    Jun 1, 2017
    Posts:
    10
    Thanks for the fast reply, Spelltwine.

    Which version of Unity are you using?
    5.6.0f3 Personal

    Is this happening only with the servers hosted on Digital Ocean or also when testing locally on your computer?

    The demo worked fine locally, although I didn't test it with multiple users, so that doesn't really help does it? :/

    Does this happen if you try to connect only with Windows game clients?

    No, it happens on whatever client clicks the 'Game Rooms demo' button second (testing on Android and Windows). The first client is allowed in and proceeds to the next scene as normal.

    Are the servers still up and running after you receive the error on the second client?
    I have verified using the 'top' command on my Digital Ocean droplet that master_server and zone_server are still running after the error message.

    I also double-checked my firewall settings this morning and they look exactly as the documentation recommends.

    Perhaps I am building the binaries incorrectly?

    I am new to Unity, so could easily have made a silly mistake.

    I built the game_server, zone_server, and master_server separately in Unity. That is, I placed the master server scene into the Built Settings ALONE and then changed the target platform to Linuxx86_64, checked the Headless box and built it. I then removed the game server scene and added the master server scene, built it, and did the same for the zone server.

    Since the documentation did not specifically say anything about which scenes to add to the build settings, I wasn't sure if this was correct or not.

    Thanks!
     
  42. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Thank you for the information! It looks like you are doing everything right (the scenes needed for the builds are documented here).

    Could you please try running the demo locally with multiple game clients? It could also be worth it to try everything with Unity 5.5.2 (the version used to submit the asset).
     
  43. onesoftgames

    onesoftgames

    Joined:
    Dec 27, 2016
    Posts:
    6
    Hi Spelltwine!
    Can I use MSK for making real-time multiplayer like Tank Battle 1990 (Two players co-op in the same level )? Or a tank game just like https://www.assetstore.unity3d.com/en/#!/content/80165 ?
    And do you have any link for how to write the logic of game in MSK? I just beginning learn how to code multiplayer game so please help!
    Thank so much!
     
  44. codyraymiller

    codyraymiller

    Joined:
    Jun 1, 2017
    Posts:
    10
    Same error on a local build. :(



    The top screen is my main PC and the bottom is my laptop. Both are running the latest version of Windows 10. I also verified that MasterServer.exe and ZoneServer.exe (along with GameServer.exe when I launch the client) are running. I see them in Windows task manager.
     
  45. codyraymiller

    codyraymiller

    Joined:
    Jun 1, 2017
    Posts:
    10
    Actually, I'm not sure what is going on with the Server.exe components now. GameServer.exe is not being executed when I launch the GameClient. Perhaps I misunderstood how this is supposed to work? Which server exe(s) should I be launching manually before running the GameClient on my local PC?
     
  46. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    You want to launch the master server and the zone server before testing the game clients. The game server instances will be automatically spawned as new games are created.

    From your screenshot, I assume you are running the master server and the zone server from your main PC and the game client running in that computer is working fine. The fact that the client does not work on your laptop is actually expected, as your laptop will not be able to connect to your main PC's master server running on localhost (unless you tinker with your network settings). What I meant by testing several game clients locally was referring to multiple clients on the same machine (you can build them as windowed applications in order to test them more easily). That should definitely work and, from there, moving to a dedicated server setup is mainly a matter of uploading the server builds pointing to the server's publicly accessible IP address.
     
  47. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Thank you for your interest!

    The kit provides custom matchmaking, player authentication and player data storage functionality that helps you have your UNET-based game on a dedicated server setup, but it does not provide any facilities for writing the game logic itself. In that regard, it is required that you know how to use UNET in order to write your multiplayer game logic. The kit will not help you there.

    A good starting point to learn UNET are the official tutorials. You can use the free tier of Unity Services while you are learning and, once you are more comfortable, move to a dedicated server setup with Master Server Kit. The transition is basically seamless, as your game code will be unaffected (you will only need to change the matchmaking calls, which is trivial).
     
  48. codyraymiller

    codyraymiller

    Joined:
    Jun 1, 2017
    Posts:
    10
    Ok. I feel really silly right now. Of course the laptop can't reach a local server. *facepam*

    But here's what's happening now on the local machine:

    - GameServer.exe is never running.
    - GameClient.exe (1) can enter the server browser scene without error.
    - GameClient.exe (2) receives the same error as with my dedicated server

    Here's a screenshot:

     
  49. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Could you please send me your entire project to the support email so I can test it on my end?
     
  50. codyraymiller

    codyraymiller

    Joined:
    Jun 1, 2017
    Posts:
    10
    Sure. It is rather large because I have a lot of work in progress scenes and assets in the project right now, but I've zipped it up and will send you an email shortly.
     
Thread Status:
Not open for further replies.