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. yuyu_bibibobibo

    yuyu_bibibobibo

    Joined:
    Dec 17, 2017
    Posts:
    1
    thanks for your addon,wish you can do a tutorial in youtube,i want to purchase that,because i am noob for c#,and my english is sick,so plz do some tutorials,sorry for my terrible english..
     
  2. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Could you please describe in more detail what tutorials would you be interested in?
     
  3. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    Is there a specific place where you should put your builds on linux server?
    Like /var/www/
    or anywhere ?
     
  4. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Not really; feel free to put them wherever you like.
     
  5. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    I am at the point where i am testing my game on a linux virtual machine.
    I cant get the client to connect to the MasterServer wich is running on my VM.

    You asked @yuyu_bibibobibo what kind of tutorial he will be interested in, me i would say a tutorial on a deploiment on a simple VM from scratch, it should not be too long and would simplify the linux side of hosting too.

    [edit]
    For example: when connecting to my sql database from the MasterServer, do i need to put the id:
    127.0.0.1 localhost - Or - do i need to put the public ip ? for now, i can't connect to the mySql database.
     
    Last edited: Jun 11, 2018
  6. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    There is already one here. If you have any further questions, please use the contact form at our website (sorry to insist on this, but this thread is exclusively for announcements and pre-purchase questions).
     
  7. Sphelps

    Sphelps

    Joined:
    Jun 9, 2013
    Posts:
    243
    Does anyone have a way for the user to logout of the authentication system.
    Cant seem to find the location how to do it.
     
    Last edited: Jun 14, 2018
  8. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Both the master server and game clients in the ClientAPI are wrappers over UNET's NetworkClient; you can call their Disconnect method (although you may need to write additional logic depending on what you want to do in your game).
     
  9. Sphelps

    Sphelps

    Joined:
    Jun 9, 2013
    Posts:
    243
    Guess I could call a disconnect and a reconnect
     
  10. lThanatosl

    lThanatosl

    Joined:
    Jan 25, 2013
    Posts:
    40
    Hello,

    I just bought the asset and i got a question:

    - is there a way to just launch one .exe and play the game? Having the player launch 2 .exes seems very odd and not something you see in many games at all. (Plus it's very annoying seeing Unity's launcher twice as well).
     
  11. gamevanilla

    gamevanilla

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

    For support questions, please use the contact form at our website. This thread is exclusively for announcements and pre-purchase questions.
     
  12. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    406
    Interesting! I’m at the verge of choosing a network solution for my RTS game and keep reading a lot saying photon is better than unet etc.

    However if I understand this correctly, I can build a ”normal” unet networking and get it working, and then apply this to switch from client server to a master server instead?

    How do you recommend dealing with cheats/hacks? Didn’t find anything about this in the docs but I might have missed it.

    What’s the advantage of this compared to Photon server and Forge networking master server?

    Thanks, looking forward to get started!
     
  13. gamevanilla

    gamevanilla

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

    I am not familiar with Photon or Forge myself, so I cannot provide a comparison with them. But, with regards to Master Server Kit, that is right: it makes it possible to run a UNET-based game on a dedicated server (as opposed to Unity Services, where one of the players acts like a server and a client) and provides some additional functionality like player authentication, player data storage and custom matchmaking. The transition from Unity Services will usually be seamless, except for code that has been written assuming the client and the server are the same entity.

    There is no built-in functionality for dealing with cheats or hacks in the kit, as that is a very game-specific area; generally speaking, you want to make sure to write your multiplayer code in a server-authoritative way.
     
  14. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    107
    I can't open the online documentation. Seems like your site is down?
     
  15. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Seems to be accessible on my end. Note that we migrated it a few versions ago; it is now hosted here.
     
    hottabych likes this.
  16. tkaczu

    tkaczu

    Joined:
    Aug 8, 2013
    Posts:
    6
    I have a question, When players creates a game when they are loged in, the game is hosted by them and master server only sends info about this server to others ? Am I correct ?
     
  17. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    No; games are always hosted on the dedicated server and never by any specific player. That is the main difference of using the kit as opposed to using Unity Services. You can find more information about how the kit works here.
     
  18. farid13

    farid13

    Joined:
    Aug 25, 2016
    Posts:
    3
    For now for each new server we need to build new instance from Editor.
    Is it possible to add command line options for "IP", "port", and "properties" (to existed like '-batchmode') ?
    It would simplify deployment process.
    Thanks!
     
  19. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    I had had a similar issue and ended up creating a config file to read on Awake(). It's just a plain text file that goes in the streaming assets folder that contains IP and any other information you wanna set. Then you can just build once and edit the config file for each separate copy you need running.

    Kinda of a pain having it in the streaming assets folder since I forget to save it when I delete and copy a new build over and gotta re-edit it every time. Might be possible to read a file from outside the data directory to make this less likely to happen accidentally.

    Would potentially do what you need and not require you to enter command line options every time you start.
     
  20. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Thank you for your feedback! Definitely noted for the next update.
     
  21. zenforhire

    zenforhire

    Joined:
    Nov 5, 2012
    Posts:
    65
    Looks like we could use your asset but have feature questions.

    o I don't see the group/team of Players abstraction.
    My use case is an arena of 4 teams. Let's say 4 players per team. As they join game, they must select a team.
    Looking at documentation, I don't see team abstraction in lobby.

    o Not sure the separation of the Lobby and my Game.
    My game has to have logic for groups/teams management? I consider this part of the Lobby because players are still moving between teams before Game is started.
     
  22. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Unfortunately there are no team-related features in the kit.
     
  23. farid13

    farid13

    Joined:
    Aug 25, 2016
    Posts:
    3
    @SpaceMomo Thanks for idea!
    @gamevanilla Thanks for future update in advance ;)

    I found out that MasterServer starts WebGL server by default but not used, may be this also should be configured.
     
  24. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Noted!
     
  25. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374
    Since Unet is being depricated and removed completely after 2018.4... will this asset have problems to function thereafter or do you expect this incidence?

    Thanks!!
     
  26. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    That is a good question! It is hard to be specific because the new networking system is not available yet, but it is my intention to maintain the kit for as long as it makes sense to do so.

    An important thing to note is that, when using the kit, your game runs on a dedicated server of your own. So everything will keep working for as long as you want to because there is no dependency on any third-party service to begin with.
     
    Barritico likes this.
  27. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374
    Thanks!!! Quick and clear... amaizing!!!

    Another question and I buy it.

    My game is car racing. I intend to be able to put up to 30 pilots on a server. I have read (I'm new to multiplayer) that the collisions are not very successful and some mention that photon is the best option for this type of game. I know the question is complicated, so I'm going to make it easy.

    UNET is a good option for a game with these characteristics?

    Thank you.
     
  28. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    You are welcome!

    If you are new to multiplayer programming, I highly recommend working on that before purchasing the kit. Mainly because the kit will not really help you with the logic of your game; it provides the back-end functionality (player authentication, player data storage and custom matchmaking), but you are responsible for writing the 'game' part of your game.

    With both UNET and Photon, you will need to implement your own client-side prediction, interpolation and lag compensation code. That kind of code is very game-specific, which is the main reason networking libraries do not provide out-of-the-box, universal facilities for it, and also not exactly trivial (particularly if you are new to multiplayer programming).

    I would recommend playing a bit with the tutorials of both libraries and see which one feels better to you. I believe there are several racing assets available on the Asset Store which can also help you get started, but I am not personally familiar with any of them.
     
    Barritico likes this.
  29. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374
    Thanks a lot!!!!
     
    gamevanilla likes this.
  30. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    Hello, did someone succed to use send from gameServer to masterServer and back from masterServer to gameServer.
    I am struggling on this simple thing, dont know what i do wrong.
    i am taking the netMsg from
    GameRoomsMasterServerAddon.RegisterGameServer()
    then i use:
    netMsg.conn.send();
    On the gameServer i think i registered the handler right in the GameServer.StartListening():
    webGLServer.RegisterHandler(MatchmakingNetworkProtocol.RequestSetRoomIdOnGameServer, OnSetGameId);
    But nothing happens..
    Can someone help on that ? I am near the release and this little thing is blocking me!
    thanks
     
  31. RacketRebel

    RacketRebel

    Joined:
    Jun 3, 2017
    Posts:
    7
    Make your own ServerAddon for the game server to send messages from the Gameserver to the MasterServer
    and listen to the messages Send by the Masetrserver

    Code (CSharp):
    1. namespace MasterServerKit {
    2.  
    3.     /// <summary>
    4.     /// This  ServerAddon is responsible for managing the network aspects.
    5.     /// MyGameServer is your instance of the GameServer
    6.     /// </summary>
    7.     public class GameServerConfigAddon : ServerAddon {
    8.  
    9.         private MyGameServer server;
    10.      
    11.         protected override void RegisterNetworkHandlers() {
    12.             base.RegisterNetworkHandlers();
    13.             server = (MyGameServer)baseServer;
    14.             // start coroutine to get the connection and sets the network handlers.
    15.             // then this network items works allways also if the gameserver is started before the masterserver.
    16.             StartCoroutine("GetGameToMasterServer");
    17.         }
    18.  
    19.         protected override void UnregisterNetworkHandlers() {
    20.             server.gameToMaster.UnregisterHandler(NetProtocolServers.GameServerUpdate);
    21.             base.UnregisterNetworkHandlers();
    22.         }
    23.  
    24.         protected virtual void OnGameServerUpdate(NetworkMessage netMsg) {
    25.             var msg = netMsg.ReadMessage<NetServerInfo>();
    26.             // do your stuff
    27.             ///
    28.             server.gameToMaster.Send(NetProtocolServers.UpdateRespons, responsMsg);
    29.         }
    30.  
    31.         IEnumerator GetGameToMasterServer() {
    32.             yield return new WaitUntil(() => {
    33.                 bool masterAvailable = false;
    34.                 if (server.gameToMaster != null) {
    35.                     if (server.gameToMaster.connection != null) {
    36.                         if (server.gameToMaster.isConnected) {
    37.                             masterAvailable = true;
    38.                         }
    39.                     }
    40.                 }
    41.                 return masterAvailable;
    42.             });
    43.             server.gameToMaster.RegisterHandler(NetProtocolServers.GameServerUpdate, OnGameServerUpdate);        
    44.         }
    45.  
    46.     }
    47. }
    48.  
    And on the master server the same structure but then the your GameServer is the registered server.
    And make your own GameRoomsMasterServerAddon

    Code (CSharp):
    1. namespace MasterServerKit {
    2.  
    3.     public class GameRoomsMasterServerMyAddon : GameRoomsMasterServerAddon {
    4.  
    5.         MasterServer server;
    6.  
    7.         protected override void RegisterNetworkHandlers() {
    8.             base.RegisterNetworkHandlers();
    9.             server = baseServer as MasterServer;
    10.             NetworkServer.RegisterHandler(NetProtocolServer.Request, OnRequestForData);
    11.         }
    12.  
    13.         protected override void UnregisterNetworkHandlers() {
    14.             NetworkServer.UnregisterHandler(NetProtocolServer.Request);
    15.             base.UnregisterNetworkHandlers();
    16.         }
    17.  
    18.         protected virtual void OnRequestForData(NetworkMessage netMsg) {
    19.             var msg = netMsg.ReadMessage<NetMessageJudgeRequest>();
    20.             if (msg != null) {
    21.                 var registeredGameServer = registeredGameServers.Find(x => x.id == msg.id);
    22.                 var responsMessage = new NetMessageData();
    23.                 var success = true;
    24.                 if (registeredGameServer != null) {
    25.                     Property myProp = registeredGameServer.properties.Find(x => x.name.Contains("myprop"));
    26.                     if (myProp != null) {
    27.                        // add / change get data
    28.                     }
    29.                 }
    30.                 // do your stuff
    31.                 netMsg.conn.Send(NetProtocolSever.Respons, responsMessage);
    32.                 // OR
    33.                 registeredGameServer.connection.Send(NetProtocolServers.Respons, responsMessage);
    34.             }
    35.         }
    36.  
    37.     }
    38. }
    Maybe this solves your problem.
     
    gamevanilla likes this.
  32. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    @rnb-it
    Thank you 1000 times, i try to adapt this to my needs, and i come back to show you the result!
    Thanks again !!
     
  33. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Hello! Version 1.18 of the kit is now available:
    • All the servers in the kit now support command line arguments to specify their related IP addresses and port numbers. You can find more information about how this works here.
     
    vertexcolor likes this.
  34. Bingo_it

    Bingo_it

    Joined:
    Dec 27, 2017
    Posts:
    1
    I want to implement Dissonance Voice Chat with master Server kit. Can anybody help me in it.
    Thanks in advance
     
    Nyarlathothep likes this.
  35. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    hi - I am trying to build a linux build in headless mode. When I go to Window > Master Server Kit > Build All it still builds windows builds event though I have Linux and headless selected?

    Do I need to build everything separately as linux builds?

    upload_2018-11-13_16-44-18.png
     

    Attached Files:

  36. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    You need to change the platform in the Builder script. It would be nice to automatically detect the editor's platform, though. Definitely noted!
     
  37. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    go tit cheers :)

    I now have it all built as linux. Do I need to make the path to the binary just game_server.x86_64 or do I reference the folder like this:

    /home/game/game_server.x86_64

    in the Zone Server component?

    I am using ubuntu and logged in as root

    btw really appreciate the help :)
     
  38. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Just the name should be enough as long as your binaries are all in the same location.
     
  39. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200
    I have the files running on the server (see screenie below) but I cant connect to the server from the game?

    btw I have my firewall on my server turned off right now.

    upload_2018-11-13_19-32-2.png

    upload_2018-11-13_19-32-48.png
     

    Attached Files:

  40. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    If a connection cannot be established, it usually means the port is not accessible to the outside for some reason, but it is hard to be more specific than that without any context. If you still have problems, please use the support contact form; this thread is more for announcements and pre-purchase questions.
     
  41. Barry100

    Barry100

    Joined:
    Nov 12, 2014
    Posts:
    200

    did you ever get the amazon situation fixed? I am in the same boat. I can not get a connection to amazon. Also when I have the masterserver running it seems to never be listening on any port
     
  42. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    Unfortunately I did not have any luck getting it to work on AWS. I sent a private message with extra details.
     
  43. errorsevendev

    errorsevendev

    Joined:
    Sep 29, 2016
    Posts:
    8
    Any way of supporting multiple player prefabs with this?
    Thanks
     
  44. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Not built-in, as we use the regular Network Manager in UNET.
     
  45. abgamers

    abgamers

    Joined:
    Dec 22, 2009
    Posts:
    97
    Hi, I'm facing a strange problem with my MasterServer kit which happens running for a very long time.

    As explained by the documentations I have placed my 3 servers (MasterServer, ZoneServer & GameServer on my server in the same folder.

    My App is working As expected, I'm able to connect to my Game room when every I make request at start.
    But after a very long time ( few days some times its on 2nd day and some time it will work fine till 10-15 days no fixed pattern) Im not able to connect to the GameServer room.
    This problem is fixed by just restarting my ZoneServer.

    The Game room is created when the client request, The app even gets a notification from server that the room has been create. And my app call JoinRoom call as well. but before it could join the GameServer app is destroyed on server itself.


    Im not sure what the problem is,

    If will be of great help if some one can help me out with this issue.

    Thanks In Advance :)
     
  46. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    The game server closes itself after some time has passed (30 seconds by default) with no connected players, but only if the Close when empty setting is enabled. Is it possible that your server is timing out sometimes when a player is trying to join the game server (causing the game server to automatically close itself before the player is able to join)? You could test this by increasing the time period; the relevant code is located in the CloseWhenEmptyService method of the GameServer class.
     
  47. scranley

    scranley

    Joined:
    Dec 1, 2013
    Posts:
    9
    Hello,

    Is it possible to setup offline multiple, such as the offline multiplayer in clash of clans? For example, a player can build their fort and log off. Then another player can attack their fort while they are not logged on. Also this involves replays. Can this store replays or would that have to be programmed separately or found in another asset?

    Thanks,

    Seamus
     
  48. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Unfortunately not; everything is focused on non-persistent, real-time session-based games.
     
  49. abgamers

    abgamers

    Joined:
    Dec 22, 2009
    Posts:
    97

    Hi Gamevanilla,
    Thanks for replying back, I don't think its a time out issue. As my Timeout Time is 120 seconds but my GameServer quits itself in less than 1-2 seconds after it is created. Also as I said as soon as I restart the ZoneServer it works fine without any problem. Its really hard to debug it as well as this issue pops in after uncertain period of time sometimes it can happen after 2 hrs or sometime after 2 weeks.

    I'm not sure how i should handle this problem now.

    Thanks
     
  50. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Hard to say from my end but sounds like something specific to your setup; I have not received any similar reports so far.
     
Thread Status:
Not open for further replies.