-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Received a packet with an invalid Magic Value" due to huge message #3143
Comments
Are you using the default UnityTransport or a 3rd party transport? |
We're using the default UnityTransport, installed automatically as a NGO 1.11.0 dependency. |
@scs-b For both this issue and #3153, if you are using Unity relay then my next question is whether you have you run the same kind of burn in tests locally without the use of relay or any services and if so do you get the same issue ? |
@NoelStephensUnity Old implementation: // Server
private void SynchronizeState(AppState message) {
SetLocalState(message).Forget();
using var writer = new FastBufferWriter(1024, Allocator.Temp);
writer.WriteValueSafe(message);
NetworkManager.CustomMessagingManager.SendNamedMessageToAll(Constants.AppStateMessage, writer, NetworkDelivery.Reliable);
}
// Client
private void ReceiveMessage(ulong senderClientId, FastBufferReader messagePayload) {
messagePayload.ReadValueSafe(out AppState newState);
SetLocalState(newState).Forget();
} New implementation: [Rpc(SendTo.Everyone)]
private void SynchronizeStateRpc(AppState message) {
SetLocalState(message).Forget();
} We haven't had issues with larger network messages that contain the entire game state, so I thought the issue might be that this message was too small. I changed this method to an RPC as well just to be sure. private void SendMessage() {
using (var writer = new FastBufferWriter(1024, Allocator.Temp)) {
_appManager.NetworkManager.CustomMessagingManager?.SendNamedMessageToAll(Constants.RecentreMessage, writer, NetworkDelivery.Reliable);
}
} We successfully ran our burn in test for up to 3 days without any issues. We are not using relay, and we are using a pure server - it does not double as a client. Hope this helps! |
@scs-b Glad you got past the issue...but if/when you have time it would help us track down where the buffer corruption was happening. |
@NoelStephensUnity public struct InitState : INetworkSerializable, IDisposable {
public LevelType Level;
public NativeList<SyncedViewType> ViewTypes;
public NativeList<SyncedPosition> Positions;
public NativeList<SyncedRotation> Rotations;
public NativeList<SyncedOwner> Owners;
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter {
serializer.SerializeValue(ref Level);
serializer.SerializeValue(ref ViewTypes);
serializer.SerializeValue(ref Positions);
serializer.SerializeValue(ref Rotations);
serializer.SerializeValue(ref Owners);
} The message that we replaced with an RPC was just sending an public enum AppState {
Boot,
Connecting,
Lobby,
Game,
} #3153 ended up being a bigger issue for us since it was happening consistently. This magic number thing was a lot more rare. Since this change we haven't ran into any of these issues though! |
Description
This bug has only happened a few times in the past 6 months, and we're not sure what's causing it.
We are letting the game run on repeat for hours or days, and this happened after successfully running the game for over 24 hours.
The log says that the client received a seemingly huge message, but the server is not complaining about trying to write too much to the FastBufferWriter. This is how we send the message;
Error message
Environment
The text was updated successfully, but these errors were encountered: