Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

UNet open to internet (port 7777 closed)

Discussion in 'UNet' started by Slences, Aug 3, 2015.

  1. Slences

    Slences

    Joined:
    Jul 15, 2015
    Posts:
    4
    I have port forwarded 7777 on my router but it remains closed whenever I start a host in Unity 5. I'm pretty sure I forwarded correctly because when I opened port 8080 and ran my webserver on it, it worked fine.

    Is UNet StartHost by default Lan only or what am I doing wrong here? I tried also puting off the firewalls both on the router and locally.

    On a site note: It seems like I can't ask any questions anymore on the answer page. Whenever I post a question I get errors that the given tags are not correct. There are also no tag suggestions whatsoever. When for example I ask a question with a simple tag like "collision", it doesn't even recognize it.
     
  2. Slandercakes

    Slandercakes

    Joined:
    Jul 30, 2015
    Posts:
    15
    Having the exact same problem, just can't seem to figure it out. The documentation doesn't really help, either.
     
    Last edited: Aug 14, 2015
  3. Xazerek

    Xazerek

    Joined:
    Nov 3, 2014
    Posts:
    134
    I have the same problem.
     
  4. ObliviousHarmony

    ObliviousHarmony

    Joined:
    Jul 3, 2014
    Posts:
    79
    Out of curiosity, what IP address are you using to attempt the connection? To better explain what I'm getting at, I've made the following diagram. It is a really simplistic demonstration of how the internet works:


    The way the internet is set up, there are many different "networks" that are networked together. When it comes to your home router, for instance, you will typically be on an IP address within the 192.168.X.X range. If you want to connect to another computer on this network, you HAVE to connect using that address. If you try to connect using the public IP address, your router will just drop the packet. However, if you send a packet with your own local address, it will also drop the packet. This is one of the reasons the loopback address exists. Now, if you want to connect to another computer across the internet, this is where port forwarding comes in. You have to forward the port, otherwise the router won't know where to send the packet. There are ways around this issue, and they are typically in the realm of NAT punch-through. Unity's (paid) solution is to use relay servers (though it's free for I believe up to 10 clients or something per game). That's a little beyond the scope of this conversation though!

    Tl;dr

    If you want to connect to your own computer, use "127.0.0.1"
    If you want to connect to another computer on your local network, use that local address.
    If you want to connect to a computer across the internet, use their public address and make sure port forwarding is enabled on their router (or use relay servers and Unity matchmaking!)

    If you have any more questions, let me know!
     
    kingandroid likes this.
  5. Xazerek

    Xazerek

    Joined:
    Nov 3, 2014
    Posts:
    134
    @ObliviousHarmony

    I have one question, cause nobody want to answer me:

    Why my friend can't make Server? He uses Enable Mathmaking choose Internet then press Start Match and nothing happens. But i can make server and join.

    Edit:
    Some people is telling me i must recreate game on Unity CLOUD.
    I didnt do anything with unity cloud, i only made a project in Unity multiplayer and i copied UPID to Cloud project id. For me all is working great but for my friends nothing happens
     
  6. Slandercakes

    Slandercakes

    Joined:
    Jul 30, 2015
    Posts:
    15
    Very helpful post - thank you.

    I've forwarded port 7777 and used my public IP as as 'Network Address' on my network manager but my friend is still unable to connect to my game over the Internet - do you have any idea why? I'm 90% sure I've opened the port correctly - do they also need to open a port or something?
     
  7. ObliviousHarmony

    ObliviousHarmony

    Joined:
    Jul 3, 2014
    Posts:
    79
    I believe they are referencing the Unity matchmaker. You can find documentation on that here: http://docs.unity3d.com/Manual/UNetMatchMaker.html I'm not using their built-in matchmaker, so I'm afraid I can't be much help there. :(


    1. You have nothing else listening on this port, right?
    2. Is your game server starting on this port?
    3. Are you sure you've entered the right IP address to forward to? If you don't have static IPs set for your computers, it's possible that you don't have the same IP address as you did when you set up the forwarding. I would verify that.
    4. Are you giving them the address found here: "http://www.whatismyip.com/"?
    5. Are you sure that their client is attempting to connect to the right IP address and the right port?

    Other than those, I can't really think of anything that would prevent your friend from connecting.
     
    liuyang61 likes this.
  8. Slandercakes

    Slandercakes

    Joined:
    Jul 30, 2015
    Posts:
    15
    Not as far as I know! Although, I'm not sure how I would find that out. It's unlikely.

    Yep - 'NetworkPort' in the network manager is set to 7777.

    It's definitely the right address. I've been trying to sort this out all day and my public IP has been the since before I tried port forwarding.

    Yep, correct address.


    Client is definitely attempting to connect to the right IP, and the port used when a client connects is hardcoded into my custom network manager script so that should also be correct.

    I'm really not sure what to try next. I understand that the entire system is still in beta, but it would be nice to actually try playing my new online game, y'know, online.

    Is there anything else you think I should try? If not, don't worry - and thanks for all of your help so far. :)
     
  9. ObliviousHarmony

    ObliviousHarmony

    Joined:
    Jul 3, 2014
    Posts:
    79
    Your public IP address, or your internal network IP address? Also, are you forwarding the UDP, TCP, or UDP/TCP port? UNet as far as I'm aware uses UDP, so that might be another issue. I can't really help too much with Unity's network manager, as I wrote my own :(
     
  10. Slandercakes

    Slandercakes

    Joined:
    Jul 30, 2015
    Posts:
    15
    Internal network address (I think? 192.168.0.*?)
    I used UDP/TCP because I wasn't totally sure which one to use - I'm also using a custom network manager, just a simple one put together through GTGD's tutorial series.
     
  11. ObliviousHarmony

    ObliviousHarmony

    Joined:
    Jul 3, 2014
    Posts:
    79
    Then it sounds like you're doing everything correctly :( Sorry that I can't be more help! You could have him try hosting a server and you connecting, maybe? That would at least help see whether it's your fault or perhaps something wrong with the game.
     
  12. Xazerek

    Xazerek

    Joined:
    Nov 3, 2014
    Posts:
    134
    So if i buy VPS, and i will host a lan game with a public ip and forwarded port, all will can join to the server?
     
  13. ObliviousHarmony

    ObliviousHarmony

    Joined:
    Jul 3, 2014
    Posts:
    79
    Well, if you use a VPS you avoid the issue entirely, as the public IP is assigned to the VPS (imagine connecting straight into a modem, rather than connecting to a router) In that case, all you'd do is put your game on it, start it up, and connect to it using the IP your provider gives you.
     
    Xazerek likes this.
  14. Xazerek

    Xazerek

    Joined:
    Nov 3, 2014
    Posts:
    134
    Nice! Thanks for help!!
     
  15. Slandercakes

    Slandercakes

    Joined:
    Jul 30, 2015
    Posts:
    15
    Tried that too, so weird!
    Tried using Hamachi and it didn't work with the standalone build - although it worked with the web player build! So I have absolutely no idea what could be wrong. I get that its in beta, but you'd think there would be a little more information about this sort of stuff in the docs.
     
  16. Slences

    Slences

    Joined:
    Jul 15, 2015
    Posts:
    4
    Anyone tried using a VPS and can confirm that it worked?