Hi @richardboegli , thanks for creating this thread. Sorry for posting in the other thread, when I did a search for
IndexOutOfRangeException: NetworkReader:ReadByte out of range:NetBuf sz:34 pos:34
UnityEngine.Networking.NetBuffer.ReadByte () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkBuffer.cs:36)
and for host id out of bound id {0} max id should be greater 0 and less than {0}, the other thread showed up, and not this one.
“Remove and re-add the network identity component on the player prefab. Make sure to hit apply” << tried this, it didn’t work for me. T-T
The other thing: when I asked people in the Unity Discord chat group, everyone was saying that Unity Networking doesn’t play well with Awake()?? All the advice that they’ve given me is to either not use Unet or not use Awake(). Is that true???
Anyway, I’m gonna repost my question from https://forum.unity3d.com/threads/merry-fragmas-3-0-stopped-working.448278/#post-2902042 here so everything’s all in one place. (Also, I spent a long time gathering all this data, that’s why I didn’t refresh that other page lol!)
I have the same error message, but my progress was towards the end of the 2nd video. So it was only until after I did the IK for the hands in the 2nd video (https://unity3d.com/learn/tutorials/topics/multiplayer-networking/merry-fragmas-30-ui-graphics-and-animations?playlist=29690), then I started getting these errors. But prior to that step, everything worked properly the same way as the tutorial.
```csharp
host id out of bound id {0} max id should be greater 0 and less than {0}
0x0000000141509B9B (Unity) StackWalker::GetCurrentCallstack
0x000000014150B84E (Unity) StackWalker::ShowCallstack
0x00000001414DA963 (Unity) GetStacktrace
0x00000001411DCBFA (Unity) DebugStringToFile
0x00000001411DD06C (Unity) DebugStringToFile
0x0000000140CC8ED3 (Unity) UNET::NetLibraryManager::CheckHost
0x0000000140CD013A (Unity) UNET::NetLibraryManager::popDataFromHost
0x00000001416BDB3E (Unity) NetworkTransport_CUSTOM_ReceiveFromHost
0x0000000027F21807 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Networking.NetworkTransport:ReceiveFromHost (int,int&,int&,byte[],int,int&,byte&)
0x0000000027F1B330 (Mono JIT Code) [NetworkClient.cs:698] UnityEngine.Networking.NetworkClient:Update ()
0x0000000027F1AD0D (Mono JIT Code) [NetworkClient.cs:950] UnityEngine.Networking.NetworkClient:UpdateClients ()
0x0000000027F1A984 (Mono JIT Code) [NetworkIdentity.cs:1073] UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate ()
0x000000000D090A8E (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
0x00007FFFCE9154A3 (mono) [mini.c:4937] mono_jit_runtime_invoke
```
I get them when I click on the Network Manager in the Hierarchy. The errors keep on repeating forever even if I don't hit the play button in the editor.
Other symptoms:
**If I use the standalone instance as the host and the editor as the LAN client:**
- In the Hierarchy, neither of the players network objects appear.
- In the Scene view, none of the networked players appear (only the one inside the Construct scene appears).
- In the Game view of the editor (which is the LAN client), none of the players appear (only the one inside the Construct scene appears).
**If I use the editor as the host and the standalone instance as the LAN client:**
- In the Hierarchy, ALL the players appear.
- In the Scene view, ALL the players appear.
- In the Game view of the editor (which is the LAN host), ALL of the players appear.
- (please see the screenshot in the attachment) The FirstPersonController script and the FirstPersonCharacter of the remote/not local player are not active, even if the PlayerBehaviorInNetworking script (in the turorial, this script is called "Player") has them toggled to be active.
**For both versions:**
- The local player can move, can shoot things, and the kill count increases if the raycasts hit the "remote" player.
- There is this harsh sound like a TV with static. This sound stops when the local player's "feet" leave the ground (like when the player is jumping).
- The remote player is floating in the air, but the idle animation plays. When the "remote" player is shot, it does not play the "death" animation, and just disappears (previously, the death animation was able to play).
- The editor's console has this error message (occurred once):
```csharp
IndexOutOfRangeException: NetworkReader:ReadByte out of range:NetBuf sz:34 pos:34
UnityEngine.Networking.NetBuffer.ReadByte () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkBuffer.cs:36)[/INDENT]
```
.
- The editor's console has these warnings (multiple of them):
```csharp
[INDENT]Did not find target for sync message for 2
0x0000000141509B9B (Unity) StackWalker::GetCurrentCallstack
```
&
```csharp
Did not find target for sync message for 3
0x0000000141509B9B (Unity) StackWalker::GetCurrentCallstack
0x000000014150B84E (Unity) StackWalker::ShowCallstack
0x00000001414DA963 (Unity) GetStacktrace
0x00000001411DCBFA (Unity) DebugStringToFile
0x00000001411DD06C (Unity) DebugStringToFile
0x0000000141166C78 (Unity) DebugLogHandler_CUSTOM_Internal_Log
0x00000000322F82FB (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,string,UnityEngine.Object)
0x00000000322F81E4 (Mono JIT Code) [DebugLogHandler.cs:10] UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
0x00000000322F7B75 (Mono JIT Code) [Logger.cs:42] UnityEngine.Logger:Log (UnityEngine.LogType,object)
0x00000000322F73B6 (Mono JIT Code) [DebugBindings.gen.cs:157] UnityEngine.Debug:LogWarning (object)
0x00000000322F6E81 (Mono JIT Code) [ClientScene.cs:717] UnityEngine.Networking.ClientScene:OnUpdateVarsMessage (UnityEngine.Networking.NetworkMessage)
0x0000000023918A2A (Mono JIT Code) [NetworkConnection.cs:468] UnityEngine.Networking.NetworkConnection:HandleReader (UnityEngine.Networking.NetworkReader,int,int)
0x0000000023917EFB (Mono JIT Code) [NetworkConnection.cs:424] UnityEngine.Networking.NetworkConnection:HandleBytes (byte[],int,int)
0x0000000023917D9F (Mono JIT Code) [NetworkConnection.cs:576] UnityEngine.Networking.NetworkConnection:TransportRecieve (byte[],int,int)
0x0000000023908D83 (Mono JIT Code) [NetworkClient.cs:735] UnityEngine.Networking.NetworkClient:Update ()
0x0000000023907FBD (Mono JIT Code) [NetworkClient.cs:950] UnityEngine.Networking.NetworkClient:UpdateClients ()
0x0000000023907C34 (Mono JIT Code) [NetworkIdentity.cs:1073] UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate ()
0x000000000AFC0A8E (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
0x00007FFFCE9154A3 (mono) [mini.c:4937] mono_jit_runtime_invoke
0x00007FFFCE8683F1 (mono) [object.c:2623] mono_runtime_invoke
0x00000001411F985F (Unity) scripting_method_invoke
0x0000000140E2E1A5 (Unity) ScriptingInvocation::Invoke
0x0000000140CC5E5F (Unity) UNET::ScriptingUpdater::playerLoopUpdate
0x0000000140BC01AD (Unity) PlayerLoop
0x000000014147B5C2 (Unity) Application::UpdateScene
0x000000014147CB8F (Unity) Application::UpdateSceneIfNeeded
0x0000000141485454 (Unity) Application::TickTimer
0x00000001415477AE (Unity) FindMonoBinaryToUse
0x0000000141548DD1 (Unity) WinMain
0x0000000141863E94 (Unity) strnlen
0x00007FFFFBBC8364 (KERNEL32) BaseThreadInitThunk
0x00007FFFFBEC70D1 (ntdll) RtlUserThreadStart
```
- Whichever is the LAN client, the first person camera is not turned on & the player who is the LAN client cannot move, and floats in the air in the screen of whoever is the host.
This error message comes out sometimes, but not all the time:
```csharp
<RI.Hid> Failed to create device file: 2 The system cannot find the file specified.
```
Despite the timing and circumstances of when I started getting the error messages, the error messages seem to lean more towards a networking issue, but I'm not sure. I tried looking online but those solutions seem either unrelated to my issue, or they are just questions in the Unity forums with no answers.
__*It appears that NetworkReader.ReadByte is an array, and something is trying to access the outside of that array. Is there a way to go into the code to see what's trying to do that? Is this even a good idea??*__
On Unity 5.5.0f3, running Windows10, if that helps.
Before that, everything worked the same as the videos. So it was only until after I did the IK for the hands in the 2nd video, then I started getting these errors.
**Things that I've tried to troubleshoot:**
- I went through all the code again and through all the videos again to make sure that everything is the same and that I didn't miss anything, including the placement of scripts & GameObjects in PlayerBehaviorInNetworking script (in the turorial, this script is called "Player").
- https://forum.unity3d.com/threads/understanding-networkreader-readbyte-out-of-range-errors.361115/
The person said that they just rebuilt everything, which I did. I tried refreshing everything in the editor, applied the changes to the prefabs, and saved everything. Then rebuilt the standalone.
- http://answers.unity3d.com/questions/1170290/unet-indexoutofrangeexception-networkreaderreadbyt.html
I didn't see anything on the script that was serialized or deserialized.
- http://answers.unity3d.com/questions/1104570/unet-transport-layer-host-id-is-out-of-bound-0.html
This looks different than what we are going through.
- https://forum.unity3d.com/threads/indexoutofrangeexception-networkreader-readbyte-out-of-range-problem.368631/
This one says that it's caused by:
[quote]
- you are attempting to connect a client built from older or newer versions of the scripts to a server
- you have a mismatch in the number of bytes written and read in an OnSerialze and/or OnDeserialize method
[/quote]
I tried refreshing everything in the editor, applied the changes to the prefabs, and saved everything. Then rebuilt the standalone. Is there a cache or something that's keeping the older version of the scripts? If that's the case, how do we refresh that so it has the latest version?
- https://forum.unity3d.com/threads/host-id-out-of-bound-id-error-on-tank-demo.333596/
- http://answers.unity3d.com/questions/1104570/unet-transport-layer-host-id-is-out-of-bound-0.html
Are these the same as our problem??!??
Any help is totally welcome. Thanks in advance!! ^__^
(By the way, hi @Mike-Geig !! This is Tsai_Ming_Li from Twitch! ^__^)
(Edited formatting for clarity.)