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 Mischaal · Jan 28, 2015 at 06:59 AM · networkserverconnectionmaster

Unity Master Server Connect to own Server won't work

Hi everyone!

A standard Peer to Peer connection worked for me most of the time but for my current project I need the Unity Master Server. So I just started using it and the connection seems to work well. I'm able to create a server, register it and get the server list. But when I want to connect to the server I created I get the following error: "The connection request to 192.168.x.xxx:3000 failed. Are you sure the server can be connected to?"

I have to mention that I just started the Play Mode in Unity and ran a server. While being in this play mode session I refreshed host list and wanted to connect to exactly the server I created just a few seconds before.

So is it maybe impossible to connect to the server I'm running? That would be bad because I want to create 1vs1 sessions where the creator is the host of the match.

I also see that the IP displayed in my console is my LAN IP. But all in all I want to connect from mobile devices (connection allowed to both WLAN and mobile internet).

Again: Everything else works. The connection to the master server works fine and creating a server won't throw me an error. Just using the "Network.Connect"-Function throws the message above to my console.

Maybe I don't understand something regarding networking games so I'm very thankful for your help in advance!

Here is my connection code:

 void Awake(){
         Instance = this;
         // Set IP and Port of the Master Server
         MasterServer.ipAddress = this.MasterServerIP;
         MasterServer.port = this.MasterServerPort;
 
         // Facilitator is neccessary for NAT punchthrough
         Network.natFacilitatorIP = this.MasterServerIP;
         Network.natFacilitatorPort = this.FacilitatorPort;
     }
 
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
         
     }
 
     void OnGUI(){
         if(GUILayout.Button("Launch Server")){
             LaunchServer();
         }
         if(GUILayout.Button("Refresh")){
             print ("Pressed Refresh");
             RefreshHosts();
         }
 
         if(loadingServerList){
             GUILayout.Label("Loading...");
         }
         else{
             scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(200f), GUILayout.Height(200f));
 
             HostData[] hosts = MasterServer.PollHostList();
             for(int i = 0; i < hosts.Length; i++){
                 if(GUILayout.Button(hosts[i].gameName, GUILayout.ExpandWidth(true))){
                     print("Have public adress? " + Network.HavePublicAddress());
                     Network.Connect(hosts[i],);
                 }
             }
             if(hosts.Length == 0){
                 //print ("No Servers");
                 GUILayout.Label("No Servers running");
             }
             GUILayout.EndScrollView();
         }
     }
 
     void LaunchServer(){
 
         print("Have public adress? " + Network.HavePublicAddress());
         Network.InitializeServer(2, this.MasterServerPort, true);
         MasterServer.RegisterHost(this.GameType, "TestArenaServer", "thisIsATest");
     }
 
     void OnServerInitialized(){
         Debug.Log ("Server initialized");
     }
 
     void OnConnectedToServer(){
         print ("Connected to Server");
         NetworkLevelLoader.Instance.LoadLevel("MPArena");
     }
 
     void RefreshHosts(){
         loadingServerList = true;
         print ("Refreshing from Master Server at IP: " + this.MasterServerIP + ", Port: " + this.MasterServerPort);
         MasterServer.ClearHostList();
         MasterServer.RequestHostList(this.GameType);
     }
 
     void OnMasterServerEvent(){
         // received Host list
         print ("Finished!");
         loadingServerList = false;
     }

Best regards

Mischaal

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

2 People are following this question.

avatar image avatar image

Related Questions

Proxy Server 0 Answers

Is the master server down? 0 Answers

Unity master server down? 0 Answers

Do RPC calls get sent through Master Server or directly to the other client? 2 Answers

Network.Connect() won't connect? 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