FirstGearGames / FishNet

FishNet: Unity Networking Evolved.
Other
1.39k stars 149 forks source link

InstanceFinder.ServerManager.StartConnection(port) always return false in server build #744

Closed barsovya closed 3 months ago

barsovya commented 3 months ago

Problem: Switch Unity to dedicated server build - fishnet always disabled, InstanceFinder.ServerManager.StartConnection(port) always return false in server build.

In host mode everyting works fine, but why? Transport Tugboat.

Unity version: 2022,3,30f1 Fish-Networking version: 4.3.5R - 4.3.8R

FirstGearGames commented 3 months ago

The only time it should be returning false is if the server is already running. See code...

        internal bool StartConnection(ushort port, int maximumClients, string ipv4BindAddress, string ipv6BindAddress)
        {
            if (base.GetConnectionState() != LocalConnectionState.Stopped)
                return false;

            base.SetConnectionState(LocalConnectionState.Starting, true);

            //Assign properties.
            _port = port;
            _maximumClients = maximumClients;
            _ipv4BindAddress = ipv4BindAddress;
            _ipv6BindAddress = ipv6BindAddress;
            ResetQueues();

            Task t = Task.Run(() => ThreadedSocket());

            return true;
        }

You are probably trying to start the server after it already starts itself, maybe from the ServerManager Start On Headless setting? image

Check ServerManager.Started before connecting. If that returns FALSE check the transport which should return STOPPED TransportManager.Transport.GetConnectionState(server: true).

If you find Started is false, and GetConnectionState is also stopped, please comment here again.