Search Unity

UNET networking : I can't connect with IP

Discussion in 'UNet' started by Koesys, Aug 24, 2015.

  1. Koesys

    Koesys

    Joined:
    Jul 20, 2015
    Posts:
    18
    Hello.
    I have two buttons : create game , and join game. My code is :
    Code (CSharp):
    1.  
    2. public void StartupHost() {
    3.   SetPort ();
    4.   NetworkManager.singleton.StartHost ();
    5.   }
    6.  
    7.   public void JoinGame()  {
    8.  
    9.   SetIPAddress ();
    10.   SetPort ();
    11.  
    12.   NetworkManager.singleton.StartClient ();
    13.   }
    14.  
    15.   void SetIPAddress (){
    16.   NetworkManager.singleton.networkAddress = "192.168.0.4";
    17.   }
    18.  
    19.   void SetPort() {
    20.  
    21.   NetworkManager.singleton.networkPort = 7777;
    22.  }
    It work ONCE between my computer and my smartphone. I open the file the day after, and it didn't work anymore. I tried it in differents situations, with local IP, public IP, on different computer, with friends... NOTHING works.
    But once, it did !! I really don't understand why. Have you got an idea ?
    Also, you should now that it works fine when I start 2 games on the same computer, or in localhost.

    Half of my concrete wall fall down since I start to break it with my head.
    Thanks
     
  2. Koesys

    Koesys

    Joined:
    Jul 20, 2015
    Posts:
    18
    I just made a test by creating a wifi network on my pc, and I connect an other PC on it, and I tried to launch the game with the new local IPs, and it works !
    So my guess is that my router is a problem, even for joining a public address.
    But I should understand what happened, and how to fix that, because people could have the same problem when the app will be on the store, and I don't want that.
    Thanks
     
  3. Koesys

    Koesys

    Joined:
    Jul 20, 2015
    Posts:
    18
    New : when I try to connect to my game locally between 2 pc, using local ip 192.168.0.4, unity tells me :
    DNS resolution failed : 11001
    UNet Client Error Connect Error: 11

    Is someone in the desert understand the least thing of what happen ?
     
  4. Koesys

    Koesys

    Joined:
    Jul 20, 2015
    Posts:
    18
    Up :) Dynamic IP are certainely the problem. Is there any help ?
     
  5. LeonardNS

    LeonardNS

    Joined:
    Aug 8, 2014
    Posts:
    2
    I have the same problem.
     
  6. Koesys

    Koesys

    Joined:
    Jul 20, 2015
    Posts:
    18
  7. inewland

    inewland

    Joined:
    Dec 6, 2012
    Posts:
    20
    Ran into this problem myself and found that it was something to do with a malformed IP string. I was parsing out the IP address and port from a file and the return lines either had spaces in at the ends or something along those lines. I parsed the file by eliminating new line containers and just used a separated value between my objects (similar to JSON parsing) and that fixed it.

    My guess is that when the IP string has spaces or additional unwanted information in it, it assumes you are using a hostname and not an IP address. Therefore, DNS kicks in and the resolution error occurs. Try using a trim on your ip and port strings or hardcode your values to test.

    Cheers.
     
  8. Valentinon13

    Valentinon13

    Joined:
    Jan 13, 2015
    Posts:
    10
    I have the answer for it you need to download xammp or wamp im using wampp thane you need to bring it public whit dns than you can connect in your local router whit static ip