#Network Connections Stopped Working

1 messages · Page 1 of 1 (latest)

quartz void
#

Does anyone know what could cause network connections to suddenly start failing?

I've been setting up netcode for entities, and I had working RPC commands running + I'm moving into dynamicly creating players on network connections. This was working for ~1 hour.

While testing, the external client started failing to connect and after about 20 minutes of troubleshooting, so did the main client/server. I'm now getting this error from the main client when I try to send RPC:
[ClientWorld] Cannot send RPC 'Unity.Collections.NativeText.ReadOnly' to the server as its NetworkConnection[id0,v1] - on Entity(107:1) - is in state Connecting!

Everything Im finding online is telling me that I simply don't have my server set up properly... but this is local

#

Network Connections Stopped Working

forest flower
#

Even local, you'll need the client world to connect to the server world before you start sending RPCs

quartz void
#

Yeah, I know that. RPCs were sending previously, I have my bootstrap set up properly

#

Sorry, I should've included this:

[UnityEngine.Scripting.Preserve]
public class GameBootstrap : ClientServerBootstrap
{
    public override bool Initialize(string defaultWorldName)
    {
        AutoConnectPort = 7979;

        return base.Initialize(defaultWorldName);
    }
}
winter shadow
#

Does anyone know what could cause network connections to suddenly start failing?
Improper driver shutdown can sometimes cause this, causing the port to be held for a while. Restarting the editor (or using another port) fixes it.

quartz void
#

That crossed my mind too (not exactly the drivers), I tried switching to 7980, restarting the editor, and when that failed I tried restarting my computer entirely.

Then I started an entire new project + copied all of my code over and voila it magically works. This is still persisting in the original project

#

Im wondering if something mightve gotten corrupted?

forest flower
quartz void
#

That didnt work, but I'll definitely keep that in my back pocket in the future lol

#

still running into the same 'Failed to send RPC because the NetworkConnection is in state Connecting'

forest flower
quartz void
#

That also doesn't work, but now I cant send the RPC for testing haha. I'm assuming it's still stuck in the connecting loop

#

I disabled the burstcompiler for debugging, do you think that that might be affecting this in some way?

#

but that also doesn't make sense if the issue is in the server setup

#

Unless there's some sort of cleanup that its supposed to do that hasn't happened?

forest flower
quartz void
#

No

forest flower
quartz void
#

Thanks for that!

Running

partial struct NetCodeConnectionListener : ISystem
{
    [UpdateAfter(typeof(NetworkReceiveSystemGroup))]
    [BurstCompile]
    public partial struct NetCodeConnectionEventListener : ISystem
    {
        [BurstCompile]
        public void OnUpdate(ref SystemState state)
        {
            var connectionEventsForClient = SystemAPI.GetSingleton<NetworkStreamDriver>().ConnectionEventsForTick;
            foreach (var evt in connectionEventsForClient)
            {
                UnityEngine.Debug.Log($"[{state.WorldUnmanaged.Name}] {evt.ToFixedString()}!");
            }
        }
    }
}

Gets me the following:
[ClientWorld] NetCodeConnEvt[NID[0],NetworkConnection[id0,v1],Connecting,ConnectionClose]!

and after 60 seconds I get:
[ClientWorld] NetCodeConnEvt[NID[0],NetworkConnection[id0,v1],Disconnected,MaxConnectionAttempts]!

#

Is it possible that theres a known bug in the editor version 6000.1.5f1?

its crazy that its not even making it to the handshake, just insta closing

worn scaffold
#

It looks like there's another process listening on the same port. Possibly a latent Unity process that's already bound to the same endpoint. As Niki suggests, that can sometimes happen if the NetworkDriver is not shut down properly.

Assuming you're on Windows, you can look at which processes are listening on UDP ports with netstat -ab -p udp or for your port specifically with the following PowerShell command:

Get-Process -Id (Get-NetUDPEndpoint -LocalPort 7979).OwningProcess

Also what version of the Unity Transport package do you have installed?

quartz void
#

Going through netstat, I have no connections over 7979, plus if this port was blocked wouldn't this fail to work on the 2nd project?

Running the powershell command also gives an error for no listening programs

Unity transport is 2.5.3, and Unity Light Transport is 1.0.1 (if that one even matters lol)

#

I did run that while the game was running btw, so its not even listening for the port

#

maybe a hint in the editor logs:
Asset Pipeline Refresh

#

[Licensing::Client] Successfully resolved entitlement details
Entering Playmode with Reload Domain disabled.
[ClientWorld] NetCodeConnEvt[NID[0],NetworkConnection[id0,v1],Connecting,ConnectionClose]!

worn scaffold
#

Kinda weird that nothing shows up for port 7979 even when the game is running. It would seem to indicate that the server is not even listening for new connections. That would explain why you're stuck in the connecting state until it times out. I'm not overly familiar with how N4E manages its connections, but might worth checking if the server is indeed configured to listen for UDP connections (and not just say IPC connections from thin clients).

quartz void
#

Where would I check for that?

forest flower
quartz void
forest flower
quartz void
#

but I dont 😭 looking through the entities hierarchy with any=NetworkId returns nothing

#

actually 1 sec

#

nvm I was gonna run a search on the bootstrap but its not an entity

worn scaffold
#

What's the Play Mode Type set to? It's in the window accessed through Window > Multiplayer > Play Mode Tools.

quartz void
#

youre the goat

#

It was set to client

#

so sorry that that was so stupid lol