• 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
Question by Pyroglyph · Jun 11, 2015 at 10:47 AM · networkingphotonmaster server

Strange IP and Port when using Network.Connect()

I'm trying to set up a simple client-server system in my Unity project. In my server script I have a Network.Connect(ip, port) line which passes the IP 127.0.0.1 and port 8000 for testing. When I start my game, it crashes with this error:

The connection request to 67.225.180.24:50005 failed. Are you sure the server can be connected to?

I ran a Whois on the IP from the error and it belongs to Unity Technologies. I don't want to use Photon or a Master Server for my game (which I think this belongs to), I just want to use IP connections. Does anyone know why it is trying to connect to the Master Server (I don't think I have any Photon code running) and does anyone know how to fix this?

Server script:

 using System.Collections;
 using UnityEngine;
 
 public class NetworkManager : MonoBehaviour
 {
     private int port = 25565;
 
     private void StartServer()
     {
         Network.InitializeServer(4, port, true);
     }
 
     void OnServerInitialized()
     {
         SpawnPlayer();
     }
 
     void OnGUI()
     {
         if (!Network.isClient && !Network.isServer) {
             if (GUI.Button (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 25 - 50 + 5, 200, 50), "Start Server"))
                 StartServer ();
 
             if (GUI.Button (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 25 + 50 + 5, 200, 50), "Join localhost"))
                 JoinServer ("127.0.0.1", port);
         } else if (Network.isServer) {
             GUI.Label (new Rect (5, Screen.height - 20, 50, 20), "Server");
         } else if (Network.isClient) {
             GUI.Label (new Rect (5, Screen.height - 20, 50, 20), "Client");
         }
     }
 
     private void JoinServer(string ip, int port)
     {
         Debug.Log ("Attempting to join " + ip + " on port " + port + ".");
         //Network.Connect(ip, port);
         Network.Connect("127.0.0.1", 25565);
     }
 
     void OnFailedToConnect()
     {
         Debug.Log ("Failed to connect to server.");
         GUI.Label(new Rect(Screen.width / 2 + 100, Screen.height / 2 - 25 + 50 + 5, 200, 50), "Failed, you fucking dingus.");
     }
 
     void OnConnectedToServer()
     {
         Debug.Log("Server Joined");
         SpawnPlayer();
     }
 
     public GameObject playerPrefab;
 
     private void SpawnPlayer()
     {
         Network.Instantiate(playerPrefab, new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, this.gameObject.transform.position.z), Quaternion.identity, 0);
     }
 
     void Update()
     {
         Debug.Log(Network.TestConnectionNAT().ToString());
         Debug.Log(Network.TestConnection().ToString());
     }
 }
 
Comment

People who like this

0 Show 0
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

Answer by Bunny83 · Jun 11, 2015 at 11:32 AM

Well, you passed "true" to "useNAT" which will require a Masterserver as NAT punchthrough requires the facilitator (which is part of the Masterserver). If you don't want to use a MasterServer you should set it to false.

 Network.InitializeServer(4, port, false);

I can't guarantee that Unity won't try to connect to the MasterServer. However when setting useNAT to true you definately are using the MasterServer.

BTW: Network.TestConnectionNAT and maybe even Network.TestConnection are using the MasterServer as well.

Comment
Pyroglyph

People who like this

1 Show 1 · 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
avatar image Pyroglyph · Jun 11, 2015 at 11:36 AM 0
Share

Okay, so I set it to !Network.HavePublicAddress() as I saw somewhere else (which equates false, by the way) and it seems to work. After I fully test it, I'll mark this as correct.

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.

Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.

For more information, please read our full announcement.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Photon Networking and Team creation. 3 Answers

Multiplayer Position Sychronization problem in unity2d 1 Answer

[PUN] Multiplayer AI Handling 1 Answer

entity interpolation problems 0 Answers

photon players position 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