Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. If you're a macOS 10.13 High Sierra user take be sure to read this before updating Unity.
    Dismiss Notice
  5. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  7. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Multiplayer Via LAN

Discussion in 'Multiplayer Networking' started by LegoDude, Dec 6, 2017.

  1. LegoDude

    LegoDude

    Joined:
    Nov 14, 2015
    Posts:
    9
    Hello, So I've been trying to get my game working over a LAN connection but it won't seem to work. When I play on one computer everything works fine. But when I try to join a game hosted on one computer, from another computer. it just says connecting then times out. I understand this is a local host issue, But I'm not sure how to change it to join the IP of the host vs just local. I tried typing in the IP in the client option, but that just tries to connect then times out. In simple, I need to know how to allow one computer to connect to another computer over the same wifi. And still have all gameplay working correctly. Thanks in advance!
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    934
    Could be several issues, from connecting to wrong IP or port, to software firewall issues on the host, to some code issues in your game.
     
  3. LegoDude

    LegoDude

    Joined:
    Nov 14, 2015
    Posts:
    9
    could i get some sort of visual reference of what to put in? i feel like i might be putting in the ip or somethign in the wrong place
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    934
    Well the IP address you enter into the client is whatever IP address the host is assigned by your router. It is usually an address that starts with 192.168.x.x, 10.x.x.x, etc. The port number is whatever port number you've chosen to run your game on. It just needs to be the same on both the host and the client, and not conflict with existing network services. Generally just pick a number above 1000 and you're good. As to where to put that in visually, that depends on how you've designed the UI in your game.
     
  5. LegoDude

    LegoDude

    Joined:
    Nov 14, 2015
    Posts:
    9
    ok interesting, Cause that doesn't work, is there another step I'm missing somewhere?
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    934
    Well there's lots of troubleshooting steps you can take. If you don't understand what some of these mean then you may need to take some basic TCP/IP networking tutorials to get up to speed.

    Can you ping between the two computers?
    Depending on your OS you may have been asked if you want to allow your game to have access to the network (software firewall related question), you said yes right?
    Have you tried simply disabling the software firewall on your host computer?
    Are you running any 3rd party software firewall?
    Are you sure both computers are on the same layer 2 network, and there isn't a hardware firewall (consumer router) in between separating the networks?
    Are you sure both the client and server are the same build, and one isn't accidentally an earlier build?
    What do the player logs from your game say is happening on both the client and server?
    If it is a Windows host, you can run in a cmd prompt "netstat -a -b", when you do that while your game host is waiting for a client you should see the name of your game exe and the udp (or tcp, but probably udp) port that it is listening on. Do you see it?
    I've assumed you've run both a client and server on the same computer already and had that working, correct? It should work both with the loopback address (127.0.0.1) and the IP address assigned to your network card.
     
    Last edited: Dec 6, 2017
    Munchy2007 likes this.
  7. LegoDude

    LegoDude

    Joined:
    Nov 14, 2015
    Posts:
    9
    1. Yes
    2. Yes
    3. Yes
    4. Yes
    5. Yes
    6. Yes
    7. How to check the logs?
    8. Don't know /cant test ATM
    9. Yea, that works beautifully

    anything else that could explain the issue?
     
  8. LegoDude

    LegoDude

    Joined:
    Nov 14, 2015
    Posts:
    9
    So everytime i try to host, the Address says localhost and the port as 77777
    I assume the address should be me ip tho? IF correct how would i do that?
     
  9. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    934
    The port matters on both the client and server. The address should only matter on the client (enter the host machine's IP address, not localhost). The IP address of the host that you enter on the client is the same IP address you would use if you ping the host from the client. You'd go into your network settings, or type ipconfig or ifconfig from a prompt depending on your OS to see the IP address on the host.
     
  10. LegoDude

    LegoDude

    Joined:
    Nov 14, 2015
    Posts:
    9
    So it seems to be an issue with the wifi, testing on my home wifi works, yet on my school wifi it doesnt, could be that it's blocked. Still want to do more testing to ensure this tho. Hasnt been properly tested
     
  11. l3fty

    l3fty

    Joined:
    Mar 23, 2013
    Posts:
    74
    I had an issue ~2 weeks ago with the Windows 10 Fall Creators update, where I think they disabled network discovery by default. This prevented my project from connecting over my home network (The machines couldn't even ping each other). Enabling it on both machines fixed the issue.
     
  12. LegoDude

    LegoDude

    Joined:
    Nov 14, 2015
    Posts:
    9
    How would i change the network discovery? The idea for this game is to be playable on any wifi via LAN
     
  13. LegoDude

    LegoDude

    Joined:
    Nov 14, 2015
    Posts:
    9
    Never mind what i said above forgot google was a thing :D
    It was turned off for me which as you said was an issue when I get a chance to test will do and let you know!
     
  14. LegoDude

    LegoDude

    Joined:
    Nov 14, 2015
    Posts:
    9
    Update, Turned the network discovery on but it did nothing. Still in the same place as i was before. Still looking for answers. Any help is appreciated. Thanks!
     
  15. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    934
    It is highly likely a school wifi would have a port filtering scheme enabled to prevent what they expect would be client machines from acting as a server. Its a form of hardware firewall. I'd really be surprised if a school network did not do this frankly.

    You could contact IT at the school to see if they would whitelist specific ports for your computer's MAC address.
     
    Munchy2007 likes this.
  16. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    112
    My school do not that :p

    But.. oh wait.. my school .. :(