Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[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
    That is because:
    • When using Unity Services, the client that creates the game acts like a host (meaning it is the server and a client at the same time).
    • When using Master Server Kit, you have a separate dedicated server.
    The scripts are actually the same in both scenarios; you do not need to change anything in your game code (as long as it is server-authoritative). You are just running the server on a separate machine, completely independent from the clients.

    Related to this, I have a demo with the first steps of the official UNET tutorials running with the kit. If you are interested in checking it out, please feel free to reach me privately with your invoice number and I will be happy to send it to you.
     
  2. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    It should! Your server needs to run on a standalone platform (Windows, Linux, Mac OS) and you should be able to connect with any UNET-compatible client (which, as far as I can tell from a quick search, includes HoloLens).
     
  3. Luiz_Thiago

    Luiz_Thiago

    Joined:
    Feb 27, 2013
    Posts:
    32
    Hello! Can u explain a little more about the Standalone Game Server option? I will need run the Master Server too? I dont get it...
     
  4. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Standalone game servers are manually spawned by you (instead of being automatically spawned by a zone server). As such, they are outside the matchmaking system and therefore more useful for world-based games. You always need the master server running.
     
  5. Luiz_Thiago

    Luiz_Thiago

    Joined:
    Feb 27, 2013
    Posts:
    32
    Ty very much!

    Everything is running perfectly! Now the problem is that when running the build on Android, the game does not connect to the MasterServer (hosted locally on my desktop)... But when running a build for PC, the game connects... What can I be doing wrong?
     
  6. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    If you are hosting the master server locally on your desktop machine, only desktop clients will be able to connect to it. You will need to host the master server on a server with a public IP address and that is able to run Unity binaries (e.g., Digital Ocean, AWS, etc.) if you want external clients to be able to connect to it.
     
  7. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    The Mega Sale has started, with Master Server Kit at a 15% discount!

     
  8. ben0ki

    ben0ki

    Joined:
    Oct 30, 2017
    Posts:
    13
    Howdy, I'm wondering if you can help me. I'm looking for a solution and hoping MSK is the answer..
    I'm planning an app that allows users to login and select from one or more prebuilt levels that reside on a remote server, the user would only have access to specific levels that are associated with their account. The level would then download to the users app (a one time download), the user can then play the level in their app without having to download it again. Is this something that could be achieved using MSK?

    Edit: Or perhaps alternatively, could the list of joinable games be limited to specific users? So for example User 1 has access to games A and B, while User 2 has access to games B and C?
     
    Last edited: Nov 30, 2017
  9. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    What you are describing is a very specific workflow that would not be directly supported by the kit, but you could certainly extend it as appropriate if you feel comfortable with programming.
     
  10. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Check out Rocket Brawl! A multiplayer arena shooter game that uses Master Server Kit:

     
    surfknasen likes this.
  11. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
  12. Luiz_Thiago

    Luiz_Thiago

    Joined:
    Feb 27, 2013
    Posts:
    32
    I already published a product with your asset, the only problem is that I could not make a game server without a zone server = (
    Would you have any examples?
     
  13. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    You only need to check the Is standalone flag in your game server and launch it manually. If you need any further help, please reach us via the contact form in our website.
     
  14. SilverMalibu

    SilverMalibu

    Joined:
    Sep 7, 2014
    Posts:
    5
    Hi i've a question about public room discoverability.

    I've seen the "hide room when full" option. How to hide a room when it's not full?
    Let's say we've a public room full with 16 players. the match starts.
    Now one player disconnects, the room is no longer full, but the match is half way through and we don't want new players to join. How should we prevent the not-full public room from being seen?
     
  15. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    That is a good question! There is no automated support for this in the kit, because the exact moment in which a match starts is game-specific. But it should be doable to provide a way to hide the room manually from the game server when you want to; I will add this to my list.
     
  16. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    450
    Hello,

    Would this be a good option for these three types of games?

    1) Battle Royale, like PUBG or FortNite
    2) Old-school FPS types, like Quake 3 Arena, Unreal Tournament, Wolfenstein : Enemy territory.
    3) MMORPG

    Regarding Battle Royale, supporting 100 players in the same instance would be a problem?

    Regarding the old-school FPS, I would like to create a system just like they have. A list of servers the players can connect to, clans hosting their own servers. Is this what the asset is designed for?

    And a more specific question about the product...Matchmaking will be possible because I will be the done hosting the matchmaking server? So the matchmaking costs only as much as I have to pay for the server? Compared to UNET matchmaking and relay server where I pay Unity for providing the matchmaking service.

    Thank you!
     
  17. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    There is nothing in the kit that will help you directly with the game side. You are responsible for writing the server-authoritative game logic for your project.

    The kit is focused on the back-end features: player authentication, player data storage and matchmaking.

    That is an impossible question to answer in a general way. The maximum number of players supported in a single server will depend on the requirements of your game and the capabilities of your server.

    No, game server instances are automatically spawned as necessary but that is completely transparent to the user. In that regard, users are not able to host their own servers.

    That is right; you will only pay for your server and not for Unity Services.

    I hope this helps!
     
  18. SilverMalibu

    SilverMalibu

    Joined:
    Sep 7, 2014
    Posts:
    5
    Thanks! A manual switch to show/hide the game server would be great! I can already see all the battle-royale type of games coming xD
     
    gamevanilla likes this.
  19. Zanderfax

    Zanderfax

    Joined:
    Nov 2, 2016
    Posts:
    25
    Hello all..

    Picking up my development after a break to integrate new GUI tech and when I try starting the client I get the following message:


    NullReferenceException: Object reference not set to an instance of an object
    MasterServerKit.ClientAPI.ConnectToMasterServer (System.Action onConnected, System.Action onDisconnected) (at Assets/MasterServerKit/Core/Scripts/Client/ClientAPI.cs:128)
    NetConnection.Start () (at Assets/Scripts/NetConnection.cs:14)

    Can you tell me what Object I am missing?

    Thanks,

    Z
     
  20. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    For technical support requests, please reach me here and I will be happy to help.

    Thank you!
     
  21. Kholeslaw

    Kholeslaw

    Joined:
    May 7, 2013
    Posts:
    35
    Hi, I wanted to ask about the following features.

    I want to be able to have Instances for Dungeons and the sort. So, I would need to be able to have a Client Game, which is connected to the game-world Game Server, disconnect and reconnect to a dungeon-instance Game Server when the player triggers it, and then reconnect to the game-world Game Server when triggered to do so.

    Do "Zones" handle this?

    Also, I was wanting to know if a Client can connect to more than one remote Game Server at a time? For example, if I wanted to distribute game functionality across several servers, for example: have Multiplayer Chat handled by a separate Game Server residing on a different Host VPS.

    If this is possible, is there documentation which discusses how to do this?

    Thanks!
     
  22. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Both features should be doable to implement, but you would need to do it yourself (they are not provided by default).
     
  23. GamePowerNetwork

    GamePowerNetwork

    Joined:
    Sep 23, 2012
    Posts:
    257
    Hi @gamevanilla this asset looks great and I’m interested in buying it but I have one major question. Since this asset is mostly a backend tool, can I still use client coding such as Bolt networking to do all my other logic? I just want to use your asset for launching servers and handling zones... but I’m not comfortable with Unet for the client logic.

    So I guess my question is, do I have to use Unet with your kit?
     
  24. gamevanilla

    gamevanilla

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

    The kit's expectation is to use UNET for the game logic. While it should be technically doable to use a different networking library for the game side with some tinkering, it is not an actively supported use case. Maybe someone who has tried something like this can chime in?
     
  25. niknakgames

    niknakgames

    Joined:
    Aug 7, 2015
    Posts:
    25
    So i just sent in my game to reviewed by Apple and it was declined because the IPv6 network wasn't working. Apprently it is a requirement to be approved. Has anyone else encountered this?
    I set up a DNS record (A and AAAA) for my master server that points to both the IPv4 and the IPv6 address of the server.

    When I use the DNS hostname in Unity for the Master Server and run it on my linux box I get the following error

    ERR: Unable to find interface xxxxxx.xxxx.com
    ERR: Failed to create default vhost

    but then I can connect via Ipv6 address, but not IPv4 or the host name.

    Game server using the host name doesn't work either. I can't connect to it, but no real errors

    Any advice would be appreciated.

    https://blogs.unity3d.com/2016/05/10/unity-and-ipv6-support/
     
    Last edited: Jan 23, 2018
  26. chiapet1021

    chiapet1021

    Joined:
    Jun 5, 2013
    Posts:
    605
    Hi @gamevanilla, I've been following this asset for a long while now. I was wondering if you could provide some general insight on how easy/hard it would be to substitute your implementation of player authentication with a backend service--potentially Playfab, in my particular use case. I've combed through your wiki and I've noted that the built-in authentication method can be bypassed easily via allowing guest logins. I'm just not sure if trying to substitute it with another authentication mechanism would be more difficult.

    Playfab is accessible via web service and provides the client a session ticket/token once you've authenticated, which I would presumably handle on the master server. I'm thinking I could then have game servers require a valid session ticket upon connection to make sure the client is legitimate (it is the internet, after all). The game servers could directly validate the session ticket via the Playfab API.

    My programming skills are meager at best, but I'm pretty good at understanding the logic behind these networking concepts, at the very least. Thanks in advance for your thoughts and time. :)
     
  27. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    I am personally not familiar with PlayFab so cannot really offer any specific advice in that regard, but what I can tell is that the authentication code in the kit is very isolated from the rest of the kit. So, in principle, your approach sounds like it should be doable.
     
    chiapet1021 likes this.
  28. damnSimpleGames

    damnSimpleGames

    Joined:
    Oct 13, 2017
    Posts:
    13
    I have a question, I have a team based game where i want every member of the team to be able to choose a role for the team. It's your product capable to do something like this (of course, with custom code of my own :)). What i want to say, with this kit i will be able to make a custom matchmaker for it?
     
  29. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    It should definitely be doable with some extra code of your own.
     
  30. niknakgames

    niknakgames

    Joined:
    Aug 7, 2015
    Posts:
    25
    I actually did something similar to this. I do a guest login to the master server and playfab handles everything else. I'm sure it can be handled better, but so far it works great.
     
    gamevanilla and chiapet1021 like this.
  31. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    That is great to know, thank you!
     
  32. zazoum

    zazoum

    Joined:
    Sep 3, 2011
    Posts:
    78
    Hello, purchased the asset some hours ago, I feel a bit lost, but things slowly are getting clearer. Does the asset work with 2017.3? Or should I downgrade the Unity version?
     
  33. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Thank you for your purchase! It does work with 2017.3.
     
  34. zazoum

    zazoum

    Joined:
    Sep 3, 2011
    Posts:
    78
    I was woring about the downgrade cause when I import, Unity re-compiles the scripts and when I batch build I get this error:

    ArgumentException: The Assembly System.Configuration is referenced by System.Data ('Assets/MasterServerKit/Core/Plugins/System.Data.dll'). But the dll is not allowed to be included or could not be found.
     
  35. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    You need to change the 'Api Compatibility Level' option in Build Settings/Player Settings from '.NET 2.0 Subset' to '.NET 2.0' as explained in the documentation.
     
    zazoum likes this.
  36. zazoum

    zazoum

    Joined:
    Sep 3, 2011
    Posts:
    78
    Thank you, I had already read this, but I didn't applied... I'm an idiot :(
    Five stars to you my friend. Great Asset!
     
  37. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    No worries at all and thank you! :)
     
  38. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    I'm attempting to re-hook this up on for a test deployment to a live server but am having some troubles.

    I have 1 scene which I use for both server and clients which I normally test by using the "Lan Server Only" and "Lan Client" options in the network manager hud. I am using this scene instead of the "GameClient_Game" scene in the provided demo.

    I am also using the network manager, but I do not use "Auto Create Player" functionality. When the client attempts to join a server I instantiate the player manually by overriding "OnServerAddPlayer()" to allow me to have more control over where they are placed, what team they join etc.

    In the "GameClient_Start" scene. If I leave the network manager "Auto Create Player" option disabled my scene will not fully load when the client attempts to connect to the server. See screenshot below:

    View attachment 268488

    However, if I enable the Auto Create Player flag then the scene is correctly loaded as seen below:

    View attachment 268489

    In this "working" example the other network managers in the demo scenes for "GameServer" and "GameClient_Game" have their "auto create player" flags disabled.

    The problem with this working example is that since its using auto create player it doesn't appear to trigger the overridden OnServerAddPlayer() functionality. Preventing my game from ever starting.

    Is there a way to get the master server kit to work without relying on auto create player being enabled?

    I'm not against changing my join code but would prefer not to if there is a way to get this to work I'm not aware of.
     
    Last edited: Mar 14, 2018
  39. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    I am not personally familiar with the process of manually creating the players in UNET, so cannot really offer any specific advice in that regard, but I just did a quick test on my end (on the kit without changes) and it seems to work fine even when disabling the "Auto Create Player" field on the network managers. Please reach me via the official support form here if you are interested in the project and I will be happy to send it to you.
     
  40. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    Thanks for the reply and the quick test as well. I did have this working previously but it was so long ago I may have been relying on Auto Create Player at that time or didn't have the custom network manager I'm currently using.

    I'll spend some more time investigating more on my end first, I still have some ideas of things to try. I just wanted to make sure there wasn't anything about Auto Create Player that was obvious.

    Thanks again!
     
    gamevanilla likes this.
  41. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    Ok... So I think I've narrowed down the problem. I was able to reproduce the issue in my regular project without the master server kit involved. From what I can tell "OnClientConnect()" and "OnServerAddPlayer()" is not being called from my network manager when I'm using the master server kit.

    Code (csharp):
    1. public class MyNetworkManager : NetworkManager {
    2.  
    3.    public override void OnClientConnect(NetworkConnection conn)
    4.    {
    5.       ClientScene.Ready (conn);
    6.       ClientScene.AddPlayer(0);
    7.    }
    8.  
    9.    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    10.    {
    11.       //All the weird player spawning, position, and team assignment code i have
    12.    }
    13.  
    14. }
    This is probably why it works with Auto Create Player enabled. Since this is apparently bypassed if that option is enabled.

    I'm trying to dig through the master server kit code to see where something similar is called. Any ideas on how to solve this?

    Edit* Looks like OnServerAddPlayer() is the main culprit, but I'm assuming it's because they are both being overridden.
     
    Last edited: Mar 2, 2018
  42. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Could the fact that your custom network manager derives from NetworkManager instead of MasterServerNetworkManager be somehow related to this? MasterServerNetworkManager needs to be used on the game server side because it adds some additional code to make the kit work in concert with UNET's NetworkManager (more information here).
     
  43. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    I originally did try deriving from the MasterServerNetworkManager instead of the base Network Manager but that didn't appear to make a difference. But....

    I think I have narrowed things down a bit today. I got a very basic version of the overridden OnServerAddPlayer() method to work when used with the master server kit.

    Code (Csharp):
    1.  
    2.         public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    3.         {
    4.             //base.OnServerAddPlayer(conn, playerControllerId);
    5.             GameObject player = (GameObject)GameObject.Instantiate(playerPrefab, new Vector3(100, 100, 100), playerPrefab.transform.rotation);
    6.            
    7.             NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
    8.  
    9.  
    10.         }
    11.  
    I did two things:
    1.) The "Auto Create Player" option must be enabled in "GameClient_Game.unity" scene.
    2.) The overridden "OnServerAddPlayer()" method above must be within the "MasterServerNetworkManager" class.

    Number 2 make sense, as my custom network manager didn't appear to be used when adding players to the server whether it was a derived class or not. So if it's overridden OnServerAddPlayer() is never getting called... then obviously nothing in there is gonna work.

    Number 1 though seems different from standard unity behavior. In the project without Master Server Kit, If I have the "Auto Create Player" option enabled and have overridden OnServerAddPlayer() as shown above. I end up with double the player prefabs per uses that is connected. Even though "base.OnServerAddPlayer()" is not used. It adds 1 prefab because I'm overriding it and adding a prefab manually, and then auto create player adds its own as well. Hence why this option was disabled and I assumed it needed to continue to be disabled.

    I am still using my custom network manager in the "GameClient_Game.unity" scene which is good. Although I did replace it with the "MasterServerNetworkManager" class at one point but reverted it without anything appearing to break.

    I'm not sure if any of this info is helpful or not. I just wanted to take the time to share everything since you have always been so helpful and this package is a life saver.

    At this moment I'm on a good path to get this back up and running. I'm just going to move my custom network manager code and add it the Master Server Network Manger class instead. With the auto create player option enable I'm hoping this will all be working soon.

    Thanks again for all your replies, much appreciated!
     
    gamevanilla likes this.
  44. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Happy to hear you were able to make progress on this and thank you very much for your excellent explanation! It will surely be useful as a reference.
     
  45. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    Has anyone had success with getting this to run on Amazon Web Services? I've tried both linux and windows instances but unfortunately keep getting stuck at the same part.

    I am able to connect to the master server just fine and login. When I click "Play Now" it successfully creates a GameServer but the client is never connected to it. The client remains stuck at "Creating Game" dialog. After a couple minutes the Game Server is flagged as defunct and closed. The client is left hanging at creating game dialog.

    The only error I can see is this one in the client logs. "Log: cannot connect after {10} attempt address {::ffff:###.##.##.##:9001}" The numbers being the private IP address of the master/zone server. Which is odd since I'm surprised its ever being passed the private IP.

    GameClient_Start - Set to public IP of master server
    GameServer - Set to public IP of master server
    ZoneServer - Set to public IP of master server, and private IP of its own server(same as master server)
    MasterServer - Set to private IP of its own server(same as zone server).

    I've tried an enormous amount of IP combinations without much change. Am I correct in assuming the network managers of all the scenes are left fine as default "localhost / 7777"?

    I was worried it was related to ports but opening up everything didn't result in any change. I don't believe that is the issue but just in case the documentation for Digital Ocean set up mentions: 8000 ALLOW Anywhere. Am I correct in assuming this is TCP/UDP?

    Is it ok to have the Master Server and Zone Server running on the same machine? Or is there a requirement they need to be on separate instances/servers?
     
    Last edited: Mar 14, 2018
  46. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    This is interesting to me as i am soon going to test on real server.
     
  47. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    I'm not a 100% positive but after today I'm leaning more and more towards this being a public/private IP issue. The client log is always showing its attempting to connect to the private IP when joining the game server and I've exhausted any other ideas I can think of.

    From what I can tell Digital Ocean defaults to no Private network, which I'm assuming means no private IP: See Here. I have not found a way to disabled private ip's / virtual private cloud on amazon. though I was hoping I could just do that and see if it works but no luck there.

    I'd be interested if the tested setup for Digital Ocean had both a private and public IP?
     
  48. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    The tested Digital Ocean setup had only a public IP. I know several users have had success with AWS (for example, @surfknasen for his Rocket Brawl game), but I am not familiar with the details.
     
  49. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    Thanks for the info. I sent them a message to see if they had similar issue.

    In the meantime I decided to try digital ocean and the results are........Successful! I was able to get it up and running without issue. I can connect to the master server and gamer servers just fine. Everything appears to be working beautifully.

    I'll probably try enabling private IP on digital ocean and see what happens in the next day or two and see if that helps narrow this down further. I'd like to get the AWS issue resolved but worst case scenario i can always fall back to digital ocean.
     
    gamevanilla likes this.
  50. apexsoftworks

    apexsoftworks

    Joined:
    Oct 5, 2016
    Posts:
    29
    I understand Master Server Kit is designed to work with UNET. I've gotten MSK setup in my game. Now I'm at the stage where I need to write the game logic. I'm taking a look at Forge, and it has a lot of features which makes this process much faster/easier.

    My question is, is it possible to let MSK run with its Master Server, Zone Server, Game Server instancing, login, etc., features while letting Forge handle the game logic?

    It looks like it might be possible to use MSK and Forge side-by-side and just use Forge for game logic, but I'm not sure. Maybe you've taken a look at Forge?

    Thanks!
     
Thread Status:
Not open for further replies.