Skip to content

NetworkConfig cached Hash not cleared when switching server #2175

@Marc477

Description

@Marc477

So I noticed that if I try to disconnect from a server (for example a lobby server that doesn't manage scenes) and try to connect to another server (for example game server that manage scenes), it doesn't work, even though I setup the config on client to be exactly the same than the server I try to connect to.

I realized that the problem is because m_ConfigHash inside NetworkConfig.cs is already set and is never recalculated, even after a Shutdown(). And there are no way to clear the cache.

This is the concerned code:
https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/develop/com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs#L237-L255

Suggested solutions :

A) Add a function to clear the cache inside NetworkConfig.cs

public void ClearConfigHash()
{
     m_ConfigHash  = null;
} 

B) Don't cache on the client, or clear the cache whenever you disconnect on client
Caching makes sense on a server, because it could accept hundreds of connections... But on the client it doesn't make as much sense, because the client connects less often, and also more likely to disconnect and connect to a different type of server. Also whenever you disconnect with Shutdown(), it could reset the m_ConfigHash var. Since I believe that the cache is intended more for the server that stays online and would accept multiple connections before shutdown.

Metadata

Metadata

Labels

priority:highThis issue has high priority and we are focusing to resolve itstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions