Search Unity

Connection problem

Discussion in 'Multiplayer' started by pedrohb88, Sep 26, 2017.

  1. pedrohb88

    pedrohb88

    Joined:
    Aug 23, 2017
    Posts:
    16
    I've made an multiplayer game for 2 players, opened some gates on the firewall, activated DMZ on my router, and sended my IP to a friend to test it, it did not work. But when my friend tried to host (he has also opened gates and activated DMZ) I could connect to his server. what could it be? (My multiplayer has no script, only components).

    Also when i've tried to connect with other pc in the same router as my, only by enter the corresponding host IP in my router on the game, it worked.
     
  2. cyunide

    cyunide

    Joined:
    Sep 20, 2017
    Posts:
    9
    If it isn't the Firewall (Which you could turn off to test if you wanted) then it may likely be a problem with the port forwarding. If it works locally, you're problem is likely a problem with the network. Since it works when your friend hosts, I am 100% sure this is the problem. You need to forward the port (7777 by default) to the machine on your network running the host.
     
  3. pedrohb88

    pedrohb88

    Joined:
    Aug 23, 2017
    Posts:
    16
    I'll do some tests and return here to inform. I'm a bit confused about something... In the NetworkManager Component it has two fields: Network adress and Network Port... Changing the IP there does not change the host server IP, it is not static, right? The host server IP is nothing else than the machine IP that is hosting. Change the Network Port does not change de server port as well? So does not matter what i put there, the port remains the default (7777) ? Or it changes depending of the host?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The host server IP will be the IP address of the machine hosting the game that the client will try to connect to. The network port will be the UDP port that the server is hosting the game on, and the client will attempt to connect to. Be sure that when you have a client outside of your home network attempting to connect to your server, that you provide the IP address of your router, not the local IP address of your server. Also be sure that your software firewall settings on your server aren't blocking the server as well (modern versions of Windows will pop up a question about network access for your game generally the first time you try to host, and won't ask again no matter if you allow or block access).

    As far as router settings, you shouldn't have to enable DMZ on your router. DMZ will typically forward all ports to your server instead of just the game (this effectively opens your entire computer to the internet, not desirable unless you're sure the rest of the machine is secure). You should just forward the single UDP port (7777 by default) on your router to your server's local IP address.
     
    cyunide likes this.