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
1
Question by DotDream · Jan 21, 2014 at 10:00 AM · networkservermasterserverconnectport

Network.Connect not connecting to host data or ip address

I tried using the code below to connect to the matchmaking server and then connect over to my computer. This works perfectly on a Lan connection (Specifically on the same computer) but on different networks it does not connect at all. However, I know that the matchmaking server is working because the room name is still correctly displayed, it just does not connect to the server. I get the error message: "Unable to connect to [ip address]...". It is really weird because one: I know that my ip address is public and two: I tried connecting to the ip address with a forwarded port and that didnt work either. Im really confused....really I dont even need the matchmaking server and would prefer if I can just do portforward and it works...but no matter what I do it wont work. Can someone shine some light on this?

Thanks!

Master server code:


 private HostData[] hostList;
 private void StartServer()
 {
     Network.InitializeServer(32, 25000, !Network.HavePublicAddress());
     MasterServer.RegisterHost("NEN Server", "Room 1");
 }

 private void RefreshHostList()
 {
     MasterServer.RequestHostList("NEN Server");
 }
 
 void OnMasterServerEvent(MasterServerEvent msEvent)
 {
     if (msEvent == MasterServerEvent.HostListReceived)
         hostList = MasterServer.PollHostList();
 }
 private void JoinServer(HostData hostData)
 {
     Network.Connect(hostData);
 }
 
 void OnConnectedToServer()
 {
     Debug.Log("Server Joined");
 }

 //the buttons
 void OnGUI()
 {
     if (!Network.isClient && !Network.isServer)
     {
         RefreshHostList();

         if (GUI.Button(new Rect(100, 50, 250, 100), "Start Server"))
             StartServer();
         

         if (hostList != null)
         {
             for (int i = 0; i < hostList.Length; i++)
             {
                 if (GUI.Button(new Rect(400, 50 + (60 * i), 300, 100), hostList[i].gameName))
                     JoinServer(hostList[i]);
             }
         }
     }
 }
 void OnServerInitialized()
 {
     Debug.Log ("Ip address: " + Network.player.ipAddress);
     Debug.Log("External ip: " + Network.player.externalIP);
    
     Debug.Log ("server initialized");
 }



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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by smokemaker64 · Jun 15, 2014 at 06:46 PM

I am not good with C# at all, but i think i now what the problem is. In line 20 where you are trying to connect you are connecting to an to hostdata thats inside of an array and you have not defined the index of the array your trying to connect to.

Again i am not good with C# and i am not shure if this will work but thats what i can understand from your code and the error that it is giving.

Comment
Add comment · Share
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

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

19 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 avatar image avatar image avatar image avatar image

Related Questions

Network.Connect() never returns InvalidPassword 1 Answer

running 24 hours server in unity standard network 0 Answers

UNET : Custom Master server question. 0 Answers

How can i get real "extern" IP address ? 2 Answers

I see Servers in my Serverlist, which are not from my Game 1 Answer


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