com.unity.netcode.gameobjects
com.unity.netcode.gameobjects copied to clipboard
Received a packet with an invalid Batch Size Value
Description
When a Client connects to the Host, the Host gets the following error and the Client doesn't finish connecting. This happens with SteamNetworkingSockets
transport, not locally with UNetTransport
. I've redacted the array contents since I'm not sure if it contains personal information (in hexadecimal format) such as Steam IDs. I can provide the contents if needed.
The error does not occur on Netcode version 1.2.0
.
[Netcode] Received a packet with an invalid Batch Size Value. Please report this to the Netcode for GameObjects team at https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues and include the following data: Offset: 0, Size: 118, Expected Size: 117, Full receive array: [contents redacted]
UnityEngine.Debug:LogError (object)
Unity.Netcode.NetworkLog:LogError (string) (at Library/PackageCache/com.unity.netcode.gameobjects@469b46fabe/Runtime/Logging/NetworkLog.cs:34)
Unity.Netcode.MessagingSystem:HandleIncomingData (ulong,System.ArraySegment`1<byte>,single) (at Library/PackageCache/com.unity.netcode.gameobjects@469b46fabe/Runtime/Messaging/MessagingSystem.cs:243)
Unity.Netcode.NetworkManager:HandleIncomingData (ulong,System.ArraySegment`1<byte>,single) (at Library/PackageCache/com.unity.netcode.gameobjects@469b46fabe/Runtime/Core/NetworkManager.cs:1833)
Unity.Netcode.NetworkManager:HandleRawTransportPoll (Unity.Netcode.NetworkEvent,ulong,System.ArraySegment`1<byte>,single) (at Library/PackageCache/com.unity.netcode.gameobjects@469b46fabe/Runtime/Core/NetworkManager.cs:1654)
Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate () (at Library/PackageCache/com.unity.netcode.gameobjects@469b46fabe/Runtime/Core/NetworkManager.cs:1393)
Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@469b46fabe/Runtime/Core/NetworkManager.cs:1329)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@469b46fabe/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at Library/PackageCache/com.unity.netcode.gameobjects@469b46fabe/Runtime/Core/NetworkUpdateLoop.cs:208)
Reproduce Steps
Reproduced every time in our project. Unfortunately, I've not had a chance to set up a small test project for this (which would involve setting it up with Steam connectivity).
- Host a server using
SteamNetworkingSockets
transport. - Connect to the game as Client.
- Notice the error as the Host.
Actual Outcome
When a Client connects to a Hosted server, the Host gets the error detailed in description above, and the Client doesn't finish connecting.
Expected Outcome
The Host gets no error when a Client connects and the Client finishes connecting.
Environment
- OS: Windows 10 / Windows 11
- Unity Version:
2021.3.19f1
- Netcode Version:
1.3.1
/1.4.0
(develop) - Netcode Commit: 469b46fabe1a78032a31ab04a15490a6912dadfb (1.3.1) / 8707582a826cc42467fed4870d3f476ae26aeab4 (1.4.0 develop)
Just as a note: Good chance this happens on 1.2.0 and just isn't noticed. We added new safety checks in 1.3.1 that validate that what we received matches what we sent.
In this case, this may point to a but in the transport - the size being invalid indicates that the size we encoded in the message doesn't match the size of the ArraySegment the transport passed to us. Without having actually reproduced this yet, just as a guess, it may indicate the steam transport is passing us more data than we're actually going to process. (I.e., extra junk data at the end of the buffer.) This wouldn't have caused issues in 1.2 because we'd get to the end of what the header said we should read and just ignore any extra data that might have been after it; now we're being more strict about expecting that the transport doesn't give us junk data (which we're doing to make sure that any corruption that comes in at the transport level doesn't corrupt the SDK).
We have submitted an update to SteamNetworkingSocket transport that corrects an issue with callback such that callbacks will now work properly for Steam Game Server builds as well as Clients.
As to this issue another of our users encountered it as well and simply rolled back to v1.2.0 and all is working well for them.
As to why the data length isn't as expected I think its because the NetworkDelivery method is attached to the end of the data ... why we did that I really don't recall. I'll have a look into it and see if it can be removed without adverse impact and if that corrects for the issue in 1.3.1
In the meantime running 1.2.0 should get you around the problem
@JamesMcGhee - No need to actually remove the value from end of the packet. Just adjust the length for the ArraySegment you send us to not include it. We're just doing a very trivial check here that the length in our header matches the length of the ArraySegment we received. It's fine to add extra data to the end if you want, just account for it and don't include it in what you send to us. :)
@JamesMcGhee - No need to actually remove the value from end of the packet. Just adjust the length for the ArraySegment you send us to not include it. We're just doing a very trivial check here that the length in our header matches the length of the ArraySegment we received. It's fine to add extra data to the end if you want, just account for it and don't include it in what you send to us. :)
That is what we ended up doing, The channel was needed in transport so we just remove it from the data before handing it to NetCode on the read. That has been merged in now and should resolve this item RE SteamNetworkingSockets transport
Our project is still stuck on Netcode version 1.2.0
due to other issues that prevent us from going forth with the upgrade, but so far we have no longer encountered this issue when testing with Netcode 1.5.2
. 👍