Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AndreasX12 · Oct 20, 2013 at 10:56 AM · multiplayerserverprojectmaster

Custom master server in the Startrooper multiplayer project?

Hi. Since the Unity master server doesn't seems to work, I'm trying to make my own master server. (It keeps giving me this error: The connection request to 192.168.1.104:25002 failed. Are you sure the server can be connected to?). I then try to run the facilitator and it gives me a dialogbox showing: The program can't start because msvcr100.dll is missing. But when I click OK it does seem like it is running. I then start the Master Server and it runs without any warnings or errors. (The facilitator and masterserver is downloaded from Unity and debugged).

This is the master-server script which I have edited so that is should use my custom master-server.

 #pragma strict
 
 DontDestroyOnLoad(this);
 
 var gameName = "YourGameName";
  var serverPort = 25002; 
  private var timeoutHostList = 0.0;
   private var lastHostListRequest = -1000.0; 
   private var hostListRefreshTimeout = 10.0;
 private var natCapable : ConnectionTesterStatus = ConnectionTesterStatus.Undetermined; 
 private var filterNATHosts = false; 
 private var probingPublicIP = false; 
 private var doneTesting = false;
  private var timer : float = 0.0;
  
 private var windowRect = Rect (Screen.width-300,0,300,100);
  private var hideTest = false; 
  private var testMessage = "Undetermined NAT capabilities";
 // Enable this if not running a client on the server machine 
 // MasterServer.dedicatedServer = true;
 
 
 function OnFailedToConnectToMasterServer(info: NetworkConnectionError) {
  Debug.Log(info); 
  }
  
  function OnFailedToConnect(info: NetworkConnectionError) { 
  Debug.Log(info); 
  }
  
 function OnGUI () { 
 ShowGUI(); 
 }
 
 function Awake () {
  // Start connection test 
  natCapable = Network.TestConnection();  
  
  // What kind of IP does this machine have? TestConnection also indicates this in the 
  // test results 
  if (Network.HavePublicAddress())
  Debug.Log("This machine has a public IP address"); 
  else  
  Debug.Log("This machine has a private IP address"); 
  }
  
 function Update() { 
 // If test is undetermined, keep running
 
   if (!doneTesting) { 
    TestConnection(); 
    } 
    }
    
    
 function TestConnection() { 
 // Start/Poll the connection test, report the results in a label and react to the results accordingly
 
   natCapable = Network.TestConnection(); 
   switch (natCapable) {  
   case ConnectionTesterStatus.Error:
   testMessage = "Problem determining NAT capabilities";  
    doneTesting = true;  
     break;    
     
       case ConnectionTesterStatus.Undetermined:  
         testMessage = "Undetermined NAT capabilities"; 
           doneTesting = false;  
            break;    
             case ConnectionTesterStatus.PrivateIPNoNATPunchthrough: 
                testMessage = "Cannot do NAT punchthrough, filtering NAT enabled hosts for client connections,"   +" local LAN games only.";  
                 filterNATHosts = true;
 
    Network.useNat = true; 
      doneTesting = true;  
       break;   
         case ConnectionTesterStatus.PrivateIPHasNATPunchThrough:  
          if (probingPublicIP) 
          testMessage = "Non-connectable public IP address (port "+ serverPort +" blocked),"    +" NAT punchthrough can circumvent the firewall.";
             else    
             testMessage = "NAT punchthrough capable. Enabling NAT punchthrough functionality.";  
              // NAT functionality is enabled in case a server is started,  
               // clients should enable this based on if the host requires it   
               Network.useNat = true;   
               doneTesting = true;   
               break;     
               case ConnectionTesterStatus.PublicIPIsConnectable: 
                 testMessage = "Directly connectable public IP address."; 
                   Network.useNat = false;   
                   doneTesting = true; 
                     break;    
                      // This case is a bit special as we now need to check if we can  
                       // use the blocking by using NAT punchthrough 
                       
                         case ConnectionTesterStatus.PublicIPPortBlocked:   
                         testMessage = "Non-connectble public IP address (port " + serverPort +" blocked),"   +" running a server is impossible.";  
                          Network.useNat = false;   
                          // If no NAT punchthrough test has been performed on this public IP, force a test  
                          
                            if (!probingPublicIP)   { 
                               Debug.Log("Testing if firewall can be circumnvented");   
                                natCapable = Network.TestConnectionNAT();  
                                  probingPublicIP = true;    
                                  timer = Time.time + 10; 
                                 
                                 }   
                                 // NAT punchthrough test was performed but we still get blocked  
                                 
                                   else if (Time.time > timer)   { 
                                      probingPublicIP = false; 
                                      // reset   
                                       Network.useNat = true; 
                                          doneTesting = true;  
                                           }  
                                            break;
                                            
 
   case ConnectionTesterStatus.PublicIPNoServerStarted: 
     testMessage = "Public IP address but server not initialized,"   +"it must be started to check server accessibility. Restart connection test when ready.";
        break;  
        default:  
          testMessage = "Error in test routine, got " + natCapable;
           } 
           }
           
 function ShowGUI() {
  
  if (GUI.Button (new Rect(100,10,120,30),"Retest connection")) { 
   Debug.Log("Redoing connection test"); 
    probingPublicIP = false;  doneTesting = false; 
     natCapable = Network.TestConnection(true); 
     } 
     
  if (Network.peerType == NetworkPeerType.Disconnected) {
    // Start a new server  
    if (GUI.Button(new Rect(10,10,90,30),"Start Server"))  {
    
          Network.InitializeServer(32, serverPort); 
          
 //THIS PART IS WHAT I CHANGED //////////////////////////////////////////////////////
            MasterServer.ipAddress = "127.0.0.1"; 
            MasterServer.port = 23466; 
            Network.natFacilitatorIP = 
            "127.0.0.1"; 
 //THIS PART IS WHAT I CHANGED //////////////////////////////////////////////////////
 
 
            Network.natFacilitatorPort = 50005;
              
                  MasterServer.updateRate = 3;  
                   MasterServer.RegisterHost(gameName, "stuff", "profas chat test");  
                    }
   // Refresh hosts 
    if (GUI.Button(new Rect(10,40,210,30),"Refresh available Servers") || Time.realtimeSinceStartup > lastHostListRequest + hostListRefreshTimeout)  { 
      MasterServer.ClearHostList(); 
        MasterServer.RequestHostList (gameName);  
         lastHostListRequest = Time.realtimeSinceStartup; 
           Debug.Log("Refresh Click"); 
            }
            
   var data : HostData[] = MasterServer.PollHostList();   
    var _cnt : int = 0; 
     for (var element in data)  {   
     // Do not display NAT enabled games if we cannot do NAT punchthrough   
     if ( !(filterNATHosts && element.useNat) )   {
     
     var name = element.gameName + " " + element.connectedPlayers + " / " + element.playerLimit;    
     var hostInfo;   
      hostInfo = "[";  
        // Here we display all IP addresses, there can be multiple in cases where  
          // internal LAN connections are being attempted. In the GUI we could just display   
           // the first one in order not confuse the end user, but internally Unity will  
             // do a connection check on all IP addresses in the element.ip list, and connect to the  
               // first valid one.  
                 for (var host in element.ip)    {   
                   hostInfo = hostInfo + host + ":" + element.port + " ";  
                     }    
                     
                     hostInfo = hostInfo + "]"; 
                     
     if (GUI.Button(new Rect(20,(_cnt*50)+90,400,40),hostInfo.ToString())) { 
     // Enable NAT functionality based on what the hosts if configured to do   
       Network.useNat = element.useNat;      
           if (Network.useNat)     
            print("Using Nat punchthrough to connect");  
               else      print("Connecting directly to host");  
                       Network.Connect(element.ip, element.port);   
                         } 
                           } 
                            }
                             }
                              else 
                              {  
                              if (GUI.Button (new Rect(10,10,90,30),"Disconnect"))  { 
                                Network.Disconnect();
                                  MasterServer.UnregisterHost();  
                                  } 
                                  } 
                                  }



Now when I debug, a lot shows up in the master-server exe (cmd window) and there doesn't seem to be any errors.

Here is what really bothers me

I debug unity to my Android device and press Start Server, but nothing shows up in the master-server as it did in the Editor. Also, the server doesn't show no matter which is server or client. (It did show up when I was using the unity master server). Is it possible that my phone doesn't connect to my custom master server? And if so, how can it be fixed?

Thanks, Andreas

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

What is master server in unity is it okay to use it in my multiplayer?? 1 Answer

Can only ping the MasterServer after pinging it externally using command prompt, at the same time. 1 Answer

Receiving NAT punchthrough attempt from target 2500 failed 1 Answer

Photon and Playfab 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges