Search Unity

Network connection issue started seemingly out of the blue - need help

Discussion in 'Multiplayer' started by spaceman8, Mar 21, 2017.

  1. spaceman8

    spaceman8

    Joined:
    Jan 6, 2017
    Posts:
    40
    Hi,. I've been pulling my hair out over this and I'm not quite sure what to check next. I have a fairly basic game setup with networking support and everything was working fine, today however I just noticed a few issues that were not there before. I'm currently using the NetworkManager HUD for testing.

    1> If I select LAN Host on a standalone build I now have to click Client Ready for the game to start, before I just clicked LAN Host and when I am running in the Editor this still is the case, my player prefab would get created and off it goes.

    2> If I start the host in the standalone version and then run the game in the editor and click LAN Client I can see that the client connects but it never spawns my player prefab, nor can I see the server player however I can see an object appear that I can optionally spawn on the host side when pushing a button.

    If I do this the other way around and host in the editor and use the standalone as the client then everything works as expected which is usually how I test and therefor I am not sure what change I made that would have broke this. I am not getting any errors in the console and I have put the NetworkManager into debug mode but do not see any warnings or error messages of any kind.

    I have made a number of changes such as adding Anima2D bone animations, switching to a bump + light based sprite material, created some more assets etc.. but nothing regarding networking so I am not sure what exactly happened.

    If you have any ideas or suggestions I would love to hear them.

    Thanks!
     
  2. spaceman8

    spaceman8

    Joined:
    Jan 6, 2017
    Posts:
    40
    Doing a little more digging, I built a development build of the standalone and tried to host a game, luckily I found a null reference exception that is more than likely causing this issue.. However! Its in Unity code and am not sure what is causing it, I'll keep digging but here is the exception:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2.   at UnityEngine.Networking.NetworkTransform.SerializeMode3D (UnityEngine.Networking.NetworkWriter writer) [0x00062] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkTransform.cs:256
    3.   at UnityEngine.Networking.NetworkTransform.OnSerialize (UnityEngine.Networking.NetworkWriter writer, Boolean initialState) [0x0006f] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkTransform.cs:200
    4.   at UnityEngine.Networking.NetworkIdentity.UNetSerializeAllVars (UnityEngine.Networking.NetworkWriter writer) [0x00015] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:454
    5.   at UnityEngine.Networking.NetworkServer.SendSpawnMessage (UnityEngine.Networking.NetworkIdentity uv, UnityEngine.Networking.NetworkConnection conn) [0x000f2] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1395
    6.   at UnityEngine.Networking.NetworkServer.ShowForConnection (UnityEngine.Networking.NetworkIdentity uv, UnityEngine.Networking.NetworkConnection conn) [0x00013] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1191
    7.   at UnityEngine.Networking.NetworkConnection.AddToVisList (UnityEngine.Networking.NetworkIdentity uv) [0x00010] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:551
    8.   at UnityEngine.Networking.NetworkIdentity.AddObserver (UnityEngine.Networking.NetworkConnection conn) [0x000f0] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:845
    9.   at UnityEngine.Networking.NetworkServer.SetClientReadyInternal (UnityEngine.Networking.NetworkConnection conn) [0x00104] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1144
    10.   at UnityEngine.Networking.NetworkServer.SetClientReady (UnityEngine.Networking.NetworkConnection conn) [0x00007] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1106
    11.   at UnityEngine.Networking.NetworkManager.OnServerReady (UnityEngine.Networking.NetworkConnection conn) [0x00029] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:1009
    12.   at Spaceman.Net.ExtendedNetworkManager.OnServerReady (UnityEngine.Networking.NetworkConnection conn) [0x00018] in D:\work\coat.of.legs\dev\projects\SpaceMan2D\Assets\Scripts\Net\ExtendedNetworkManager.cs:37
    13.   at UnityEngine.Networking.NetworkManager.OnServerReadyMessageInternal (UnityEngine.Networking.NetworkMessage netMsg) [0x0001e] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:853
    14.   at UnityEngine.Networking.NetworkConnection.InvokeHandler (Int16 msgType, UnityEngine.Networking.NetworkReader reader, Int32 channelId) [0x00086] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:217
    15.   at UnityEngine.Networking.NetworkServer.InvokeHandlerOnServer (UnityEngine.Networking.ULocalConnectionToServer conn, Int16 msgType, UnityEngine.Networking.MessageBase msg, Int32 channelId) [0x0003b] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkServer.cs:1639
    16.   at UnityEngine.Networking.ULocalConnectionToServer.Send (Int16 msgType, UnityEngine.Networking.MessageBase msg) [0x0000b] in C:\buildslave\unity\build\Extensions\Networking\Runtime\LocalConnections.cs:83
    17.   at UnityEngine.Networking.ClientScene.Ready (UnityEngine.Networking.NetworkConnection conn) [0x0005b] in C:\buildslave\unity\build\Extensions\Networking\Runtime\ClientScene.cs:302
    18.   at UnityEngine.Networking.NetworkManager.OnClientConnect (UnityEngine.Networking.NetworkConnection conn) [0x0000e] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:1112
    19.   at Spaceman.Net.ExtendedNetworkManager.OnClientConnect (UnityEngine.Networking.NetworkConnection conn) [0x00018] in D:\work\coat.of.legs\dev\projects\SpaceMan2D\Assets\Scripts\Net\ExtendedNetworkManager.cs:71
    20.   at UnityEngine.Networking.NetworkManager.OnClientConnectInternal (UnityEngine.Networking.NetworkMessage netMsg) [0x0007d] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkManager.cs:919
    21.   at UnityEngine.Networking.NetworkConnection.InvokeHandler (UnityEngine.Networking.NetworkMessage netMsg) [0x0002c] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:228
    22.   at UnityEngine.Networking.LocalClient.ProcessInternalMessages () [0x000dc] in C:\buildslave\unity\build\Extensions\Networking\Runtime\LocalClient.cs:142
    23.   at UnityEngine.Networking.LocalClient.Update () [0x00002] in C:\buildslave\unity\build\Extensions\Networking\Runtime\LocalClient.cs:69
    24.   at UnityEngine.Networking.NetworkClient.UpdateClients () [0x00024] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:950
    25.   at UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () [0x00006] in C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:1089
    26.  
    27. (Filename: C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkTransform.cs Line: 256)
     
  3. spaceman8

    spaceman8

    Joined:
    Jan 6, 2017
    Posts:
    40
    Looking at the UNET source here: https://bitbucket.org/Unity-Technol...nsform.cs?at=5.5&fileviewer=file-view-default line, 256 doesnt look like an exception is possible. I'm using version 5.5 of Unity and this is the 5.5 branch of UNET code.

    I've also double checked all of my NetworkTransforms that are set to syncMode3D have a 3D rigidbody attached.

    I found someone with an extremely similar problem, but no solutions: http://answers.unity3d.com/questions/1296437/getting-a-nullreferenceexception-on-networkmanager.html

    :(
     
  4. spaceman8

    spaceman8

    Joined:
    Jan 6, 2017
    Posts:
    40
    I'm abandoning this, I feel the HLAPI is not a good fit for my game anyway since I really need it to be P2P and with these sorts of issues its a no brainer. Time to dig into the LLAPI or maybe Photon. Thanks for looking.
     
  5. MichalBUnity

    MichalBUnity

    Unity Technologies

    Joined:
    May 9, 2016
    Posts:
    18
    I have seen similar issues before and it's usually due to trying to spawn a prefab, instead of a instantiated object.

    Code (CSharp):
    1. playerObject = Instantiate(playerPrefab) as GameObject;
    2. NetworkServer.SpawnWithClientAuthority(playerPrefab, connectionToClient);
    Note that here we try to spawn playerPrefab and not the playerObject.
    There is a fix coming in a future release that makes the error message more readable.
     
  6. spaceman8

    spaceman8

    Joined:
    Jan 6, 2017
    Posts:
    40
    I don't think its my player object at all, I am using a CharacterController which is what the NetworkTransform is set to use, not syncMode3D which is what the error/stack is suggesting.