Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question [Netcode] NetworkConfig mismatch. I don't know how to fix The configuration between the server and c

Discussion in 'Netcode for GameObjects' started by chealin, Feb 3, 2023.

  1. chealin

    chealin

    Joined:
    Sep 10, 2017
    Posts:
    76
    hello

    I want to create a system that passes String values to other PCs using RPC.

    I created 2 projects and used the same code in both
    (I didn't get an error when linking multiple build files with one project before)
    *The two versions of the project are the same
    * Same version of NetCode for GameObjects in PackageManager.

    but

    [Netcode] NetworkConfig mismatch. The configuration between the server and client does not match
    I got the same error and I couldn't find the reason

    How should I fix this error?

    --
    upload_2023-2-3_10-52-57.png
    upload_2023-2-3_10-53-2.png
    upload_2023-2-3_10-53-21.png
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,515
    You cannot use two separate Unity projects with NGO. It has to be a single project.

    Why do you intend to use separate projects? Building a dedicated server is done by switching the build target to „dedicated server“ which will exclude assets not used by the server. Code separation can be achieved in various ways, mainly by using Assembly Definitions and/or custom packages.
     
  3. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    656
    You can use NGO to connect to two separate projects, just some settings on the NetworkManagers will need to match.
    (from the source code)
    Code (CSharp):
    1.                 writer.WriteValueSafe(TickRate);
    2.                 writer.WriteValueSafe(ConnectionApproval);
    3.                 writer.WriteValueSafe(ForceSamePrefabs);
    4.                 writer.WriteValueSafe(EnableSceneManagement);
    5.                 writer.WriteValueSafe(EnsureNetworkVariableLengthSafety);
    You might want to look at using custom messages for communication as network object prefabs won't match, you can probably get around this by overriding the hash though.

    I have two separate projects running using custom messages with no issues.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,515
    Which of the Netcode features are you using in your project? I mean classes like NetworkObject, NetworkTransform, NetworkVariable and so on? I'd be surprised if there weren't several self-understood NGO features that just won't work in that kind of setup.

    I wouldn't recommend this to just any developer because it's not supported (or even tested) and you have to have a compelling reason to split the project in the first place.
     
  5. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    656
    I don't need those network components as the project is an instance launcher and not tied to a particular game application. For the OP wanting to connect separate projects to just pass strings then a similar setup would work for them.
     
  6. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    Did you actually use "the same code"?
    Or did you copy/paste your code into both projects?
    Because there's a difference between using an assembly in two different projects, and creating 2 different assemblies that contain the same code.
     
  7. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,515
    If it's as low-level as sending strings or value types (structs) then I would simply rely only on Unity Transport (I believe you can use it separately from NGO) or any of the open source TCP/UDP transport/socket libraries for that matter. That would allow you to also talk to non-Unity apps.

    I was looking at your code fragments and saw it as indication that you were at least relying on ticks (time sync), connection approval, scene management and the like.
     
  8. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    656
    Unity Transport may be more suitable for some but I stuck with NGO as I know its workings and it was very easy to set it up for what was needed. The messaging classes are not too different from what I was using with RPC's.

    Those code fragments might be more on the game application side where I do make use of a lot of NGO network functionality. The launcher app doesn't use much more than connection approval and network callbacks along with unnamed messaging.
     
  9. chealin

    chealin

    Joined:
    Sep 10, 2017
    Posts:
    76


    I made it with different projects,
    The code leading to the RPC was the same for both projects.

    Looking at the answers, I knew that I couldn't connect from different projects.

    I'll have to think of another way...

    thank you for the reply.