Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

[Tutorial] Hosting your own masterserver

Discussion in 'Multiplayer' started by riekelt, Aug 8, 2012.

  1. riekelt

    riekelt

    Joined:
    Mar 12, 2012
    Posts:
    44
    Hello people from Unity3D!
    I have seen that many people are having trouble with setting up their own masterserver!
    So this is a tutorial i made special for you guys!

    Okay, first we need the masterserver software.
    I already compiled it and i will be updating it!
    So just download this:
    http://www.mediafire.com/?dqv3dc6f1y8640w
    And extract everything in a folder.

    Now open: start facilitator.bat
    And if everything goes well you will see this line at the top of the command window:
    Sent 4 bytes to port 50005

    Now open: start masterserver.bat
    And again you must see this at the top of the command window:
    Sent 4 bytes to port 23466

    You can choose to portforward them but i can't give a tutorial for that...
    Becouse every router is different!

    Ok now open your script where the server browser is and add:

    Code (csharp):
    1. MasterServer.ipAddress = "your ip";
    2. MasterServer.port = port masterserver;
    3. Network.natFacilitatorIP = "your ip";
    4. Network.natFacilitatorPort = port facilitator;
    And you are done! Congrats! You are now hosting your own masterserver. That wasn't so hard wasn't it?
     
    Tom-Kazansky likes this.
  2. JohnyZuper

    JohnyZuper

    Joined:
    Jan 7, 2008
    Posts:
    174
    Thank you for putting this together.

    I'll try to fix it myself but just so you know, when I first start up start facilitator.bat I get a System Error asking for a file called MSVCR100D.dll.
     
  3. JohnyZuper

    JohnyZuper

    Joined:
    Jan 7, 2008
    Posts:
    174
    Yes! It worked. Piece of cake. Thank you so much!
     
  4. riekelt

    riekelt

    Joined:
    Mar 12, 2012
    Posts:
    44
    Nice to hear it works :)
     
  5. SnowKrown0

    SnowKrown0

    Joined:
    Aug 8, 2012
    Posts:
    4
    Alguien que hable español me podría explicar que tengo que hacer??

    subo los archivos al host o que hago?
     
  6. ND

    ND

    Joined:
    Aug 3, 2012
    Posts:
    60
    And plz test port forwarding for them also. Because on my router I have some problems with forwarding the ports to my local ip. The router is ok and ports are shown in forwarded list, but In action the external game can not connect! And besides I used telnet command to connect to these ports. And the result was negative. I'm afraid if something's wrong!
     
  7. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    Port forwarding often doesn't work for internally-sourced packets, i.e. packets from your LAN addressed to your router's external IP address enter the router through the wrong port and don't go through the same forwarding rules.

    The facilitator is also not going to work properly behind a NAT, at least not if one of the devices trying to connect is behind the same NAT. It needs to be out in the cloud, where it can get a proper unbiased view of each client trying to connect.
     
  8. ND

    ND

    Joined:
    Aug 3, 2012
    Posts:
    60
    gfoot, you're gr8! After hours of trying hard to make it work, now you're saying it wont work:eek:
    I think you're right anyway but It's so pity then.

    //Edited:
    So what if I use 127.0.0.1 within my local connection (for starting the server) and then on the published version on the web site I use My public IP? In this situation and with Port forwarding it might work?
     
    Last edited: Aug 10, 2012
  9. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    Within your LAN, use your LAN address to access it, and you'll be able to connect to other devices on your LAN. From outside your LAN, use your public IP address and port forwarding rules, and you'll be able to connect to other devices outside your LAN. But it's unlikely that anything will let you connect a device inside your LAN to a device outside your LAN.
     
  10. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    LAN. :D

    That's all I saw from that entire post :p

    Anyways good tutorial! (I wish I'd have seen this before I went through hours staring at the computer screen like an idiot :) )
     
  11. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    If you use 127.0.0.1 then you won't be able to connect with other machines, even on your LAN. It would be fine for local testing though, with multiple clients all running on one PC.

    If you have other devices on your LAN that you want to connect then you need to refer to the facilitator using its LAN address, which will start with 10, 172, or 192. So long as you do that, devices on your LAN will be able to talk to each other.
     
    StinkyDubeau likes this.
  12. DLGScript

    DLGScript

    Joined:
    Jul 15, 2012
    Posts:
    272
  13. brat17

    brat17

    Joined:
    Feb 28, 2013
    Posts:
    1
    Thanks , it is awesome ! :)
     
  14. coffiarts

    coffiarts

    Joined:
    Jan 7, 2013
    Posts:
    33
    Has anyone ever found a solution to this problem reported by JohnyZuper?
    I am facing the same. I guess this is because I haven't compiled the server on my own machine, and that there's some mismatch between my environment and the one it was compiled on.

    According to this thread, it seems to me like it could either be caused by the way it has been compiled, or by the Visual C++ 2010 SP1 Redistributable Package missing locally on my side.

    I have already made sure that the latter is properly installed (both for x64 and x86), but to no outcome (still the same error).

    Anything else I am missing?
    Anyone else still having that problem?
     
  15. TBranan

    TBranan

    Joined:
    May 22, 2013
    Posts:
    27

    He fixed the problem himself; I'm sure if you PM him the fix he will be happy to assist.
     
  16. coffiarts

    coffiarts

    Joined:
    Jan 7, 2013
    Posts:
    33
    I already did so, but he hasn't replied. Don't want to to be too impatient though - it's just 3 days ago ;)
    I only hope that he's not gone for good. So I'd still be happy to learn whether anyone else has faced this problem.
     
  17. DjEmix

    DjEmix

    Joined:
    Feb 7, 2013
    Posts:
    11
    Hi! I fix the problem with MSVCR100D.dll downloading this file and put it into Debug folder of Facilitator. You can find this file on google.

    Thanks!
     
    StinkyDubeau likes this.
  18. coffiarts

    coffiarts

    Joined:
    Jan 7, 2013
    Posts:
    33
    Excellent, thanks for the reply, DjEmix!
    I'll give this a try asap. Might take me a couple of weeks, though, because I am currently absorbed by other issues related to my game.
    But I'll post the result here.
     
  19. coffiarts

    coffiarts

    Joined:
    Jan 7, 2013
    Posts:
    33
    Well, I did as DjEmix recommended, and I got it running indeed!
    Nice to know, thanks for the hint!!

    Anyway, to anyone interested - according to the following MSDN thread, this issue might be caused by the way the MasterServer has been compiled (though I am not sure whether it re).
    As I understand it, it should be compiled in "Release Mode" and not in "Debug Mode". Otherwise it would be necessary to distribute some dll files (likes the missing one) along with the application, but this is against Microsoft's License Agreement:
    http://social.msdn.microsoft.com/Forums/de-DE/vcgeneral/thread/73921400-35e5-4f10-9632-16da98d7f165

    Apart from that, I still understand why installing the C++ redistributable package (as described) didn't help in my case. The thread linked above is a bit confusing to me... :(
     
  20. Theinsanekiller

    Theinsanekiller

    Joined:
    Jun 1, 2012
    Posts:
    27
    How can i use this for mobile devices..??
     
  21. fjalla

    fjalla

    Joined:
    Nov 6, 2012
    Posts:
    73
    @Theinsanekiller - it's a windows software, not android or iOS. it's supposed to run on a server, nnot on a mobile device.

    Oh, and thanks @DjEmix It those work after that!

    One last problem: upon pressing Ctrl+C as said in the console to exit, the facilitator exits fine, but the master server says "Failed to remove PID file at", and exits afterwards. Is it a problem, or can I just ignore it?

    PS: would it be possible to ship a not debug build? I can't build it on my own cause of my internet connection :|

    thanks
     
  22. black pigeon

    black pigeon

    Joined:
    Mar 3, 2013
    Posts:
    7
    Just want to add,

    When you do a port-forwarding
    The port and ip that you want to forward is neither the masterserver's nor the facilitator's
    But the port and ip that you use in the game

    For example:
    function startServer(){
    Network.InitializeServer(32/*number of connection*/,25001/*port*/,!Network.HavePublicAddress()/*read on help*/);
    MasterServer.RegisterHost(gameName/*this what we search on network, suppose to be unique name*/,
    "Network II"/*plain game name*/,"network unity"/*just a comment*/);
    }

    25001 is the port that need to be forwarded
    And the ip that need to be forwarded is your own private ip (not the 127.0.0.1)

    I cant give you the details about how to set up port-forwarding here
    Because every router has different way to do this
    I use a TP-Link router , and if you do... you can watch this video about how to do it
    http://www.youtube.com/watch?v=ugaB5Vu57qE
    :)
     
    StinkyDubeau likes this.
  23. Deepschalappatta

    Deepschalappatta

    Joined:
    Jul 27, 2013
    Posts:
    8
    how to fix this error called "MSVCR100D.dll."
     
  24. Deepschalappatta

    Deepschalappatta

    Joined:
    Jul 27, 2013
    Posts:
    8
    @JohnyZuper :this application has failed to start because MSVCR100D.DLL WAS NOT FOUND..... Re installing the application to fix this problem.

    how to fix this problem pls help me...
     
  25. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    Thanks man this works great.
     
  26. GohersWay

    GohersWay

    Joined:
    Jul 23, 2013
    Posts:
    2
    are there any sort of video tutorials available for this.
     
  27. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    Does anyone have a dropbox/mediafire download for a Mac compilation of the masterserver? Thanks in advance [;)]
     
  28. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    For Linux users, PM me, and I can give you the executables: I got both running on my Dell Mini 9.

    EDIT: I can also give you guys the edited source, which fixes some code bugs that commonly pop up. Chances are, I won't be able to find this anymore in 2016, but I'll try... :D my systems have been changed a lot since I had the source on me.
     
    Last edited: Apr 8, 2016
  29. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    I might also ask: is there a way to access a cmputer inside the LAN from outside? I am having troubles connecting to my master server through the internet, even though I forwarded the ports correctly. (Local testing works fine, as well as direct connect by crossover cable.)
     
  30. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,043
  31. tomsk

    tomsk

    Joined:
    Jan 25, 2014
    Posts:
    7
    is exists linux version? :)
     
  32. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @tomsk: Yes, I can PM you the linux builds if you like. :)

    Also, check Orb's link, he might have the builds there too.
     
  33. tomsk

    tomsk

    Joined:
    Jan 25, 2014
    Posts:
    7
    yes i see Orb's link, thats all? 2 files for linux? :D
     
  34. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,043
    For the master server there isn't much you need, no :)

    (I didn't compile the facilitator or anything yet - I just put what I'm using for my own testing up there!)
     
  35. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Yes, two files, one for facilitator, and one for masterserver! ;)

    I also have the proxy server compiled if you need it.
     
  36. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    Hi,

    Thanks for the tutorial. But is it possible to host master server online so it would run 24/7 without me having to keep my machine on?
     
  37. Bionicle_fanatic

    Bionicle_fanatic

    Joined:
    Jun 8, 2013
    Posts:
    368
    That would probably take paid hosting for that, or Photon [;)]
     
  38. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    Photon has 20 CCU only for free users. Paying 90 dollars a month for 500 CCU is ridiculous even if people leave and join a game.

    So I thought using Unity's Networking would help me out. In order to do that I need to upload my master server online, giving me unlimited CCU (I think).
     
  39. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Yes, it's possible...
    ...So long as you're willing to spill a small amount of cash on a good VPS system, that is! (Not trying to be sarcastic here, that's what other people have told me. :D)

    Or the other way to do it is to have a second computer plugged into the internet all the time. That's the way I'm hoping to go once I have something to release. From reading your previous posts, this appears to be a no-go for you! :D

    EDIT: And one of those people that told me about VPS systems is Orb, so he may be able to help you! :)
     
    Last edited: Jan 22, 2015
  40. AmrixGames

    AmrixGames

    Joined:
    Jan 27, 2015
    Posts:
    16
    they always need to stay open?
     
  41. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,359
    Of course. Master Server is managing all connections and without it, Multiplayer games wouldn't work!
     
  42. toddisarockstar

    toddisarockstar

    Joined:
    Nov 28, 2014
    Posts:
    4
    this does not work. the server runs and logs the users requests but the users get nothing back but this message :"Failed to initialize network interface. Is the listen port already in use?"
     
  43. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Which port number are you using? if you're using a port that's clearly NOT for general use (port 80, anyone? :D) then it will most definitely fail. A port like 32547 (random number I came up with) would work too.

    From my experience, I pick a port range, and tell the game to generate a random integer between the lowest and highest ports, and let the master server take care of the rest, that way, there's less likelihood of a port conflict. :)
     
  44. RadialNinerGames

    RadialNinerGames

    Joined:
    Jun 22, 2018
    Posts:
    1
    Thank you for this...However does anyone know of a way I could install this onto a regular NAS system? It is a Thecus NAS. It would really be appreciated if someone could help with this. :)