Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Starting host/server, shows port is closed

Discussion in 'Multiplayer' started by notvalid999, Aug 7, 2023.

  1. notvalid999

    notvalid999

    Joined:
    Dec 4, 2022
    Posts:
    4
    [SOLVED]
    Turns out port checking tools like canyouseeme only report for tcp and not udp. I was able to have a friend connect even though it says the port is closed
    [Original post]
    I'm working on a multiplayer game using the Unity transport and netcode for gameobjects. Whenever I start host with the transport in the editor or by running a build, open port checking tools report that the port 7777 is closed. I have added the correct unity editor version as well as my build to inbound/outbound windows firewall rules, as well as the udp ports. I have port forwarded the ports on my router correctly, as starting a minecraft server works fine, even switching my transport to use the minecraft port still shows it closed during runtime.

    I have also tested another Unity game https://barji.itch.io/solely-higher as a test. Hosting a server in this game also did not show the port as open. Completely disabling windows firewall did not fix it.

    Does anyone have any tips to solve this? The game works fine on unity relay but I want to be able to test it online without using my limited free data from relay. Im on the latest LTS 2022.3.6f
     
    Last edited: Aug 7, 2023
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,117
    Do they report the Minecraft port as open?

    And NetworkManager is set to use port 7777?

    You could try changing that to another port and update port forwarding to ensure no other process is blocking that port, including a possibly already running instance or one that crashed and left the port open (a reboot would fix that).

    You may want to show or explain the port forwarding setup you did on the router side.
     
  3. notvalid999

    notvalid999

    Joined:
    Dec 4, 2022
    Posts:
    4
    [SOLVED SEE LAST POST]
    [Original response]
    I've tried a few different ports to put in the unity transport, including 7777, 25565, and I forwarded 666 just as a test. I've deleted/readded port 7777 a few times. All udp, but 25565 is tcp as well. I've rebooted, had a windows update, and updated unity version from 2022.3.5.f. I have windows, and the command "netstat -an | find "UDP" | more" shows all currently listening udp ports, and there are none for 7777 until I start my unity server, so it does not appear that any other application is using the port.

    My port forwarding is done via the MySpectrum app as I have a Spectrum router. I have forwarded the port 7777(and 25565) both udp and tcp. The port is forwarded on my main gaming pc, the same device I run unity from, and the same device I can successfully start a minecraft server from.I have tried forwarding 7777 as udp and udp+tcp, neither way works for unity.

    Here's what my Unity Network Manager looks like in editor. I have changed the port many times as I've said before, Ive used 7777,25565, and most recently 666 as you see. I've changed the adress to localhost, my internalip, and my external ip. I have a script that simply runs NetworkManager.Singleton.StartHost() or StartServer when pressing a button, and I've tried using the start server and host buttons in editor. I have no other modifications of the network manager in my scripts.

    https://imgur.com/a/0FaHop0
     
    Last edited: Aug 7, 2023
  4. notvalid999

    notvalid999

    Joined:
    Dec 4, 2022
    Posts:
    4
    Solved, turns out the port checker does not check for udp, i was able to have a friend connect even though it said the port was closed.